0

I am having issues with the following script. I don't see anything wrong here. Very basic but it is giving me a headache. Any suggestions are welcome. I am running version 5.1.37 and the error is:

Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''visit_recipes'
('id' INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
'name' text NO' at line 1
(0 ms taken)

CREATE TABLE 'visit_recipes' 
('id' INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, 
'name' text NOT NULL, 'ingredients' text NOT NULL, 
'instructions' text NOT NULL, 'created_by' INTEGER NOT NULL, 
'userip' VARCHAR(16), 'date_added' text NOT NULL, PRIMARY KEY('id'));
2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by griswolf
0

You appear to be translating from (postgresql?) where type text is the best option. In MySQL, varchar(size) is a better choice if possible. However, it does work, so I have not changed it. The syntax issue is the single quotes. If you want to quote table or column names, you need to use back-quote (`) not a normal quote ('). I've just removed your wrong quotes. This works for me:

CREATE TABLE visit_recipes (
  id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 
  name text NOT NULL, 
  ingredients text NOT NULL, 
  instructions text NOT NULL, 
  created_by INTEGER NOT NULL, 
  userip VARCHAR(16), 
  date_added text NOT NULL 
);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.