0
CREATE TABLE IF NOT EXISTS 'wp_gom_my_project' (
'my_project_id' int NOT NULL auto_increment,
'my_project_name' text NOT NULL ,
'user_id' int NOT NULL ,
'my_project_description' text NOT NULL ,
'my_project_deadline' datetime NOT NULL ,
PRIMARY KEY  (`my_project_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8

I just can't find the error.

This is the error message:

#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 ''wp_gom_my_project' ( 'my_project_id' int NOT NULL auto_increment, 'my_project' at line 1
1

6 Answers 6

5

You have the wrong kind of quotes:

  • ' is for quoting strings
  • ` is for quoting identifiers (table names, column names, etc)

Since none of your table or column names would be a keyword anyway, just don't put any quotes at all, and it will look much nicer. :)

Sign up to request clarification or add additional context in comments.

Comments

1

Dont put any quotes, use `

Try this one

Here is reference fiddle or another one with `

CREATE TABLE IF NOT EXISTS wp_gom_my_project (
my_project_id int NOT NULL auto_increment,
my_project_name text NOT NULL ,
user_id int NOT NULL ,
my_project_description text NOT NULL ,
my_project_deadline datetime NOT NULL ,
PRIMARY KEY  (`my_project_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8

Or replace ' with `

Comments

0

Table name and other fields should not be quoted.

Try

CREATE TABLE IF NOT EXISTS wp_gom_my_project (
my_project_id int NOT NULL auto_increment,
my_project_name text NOT NULL ,
user_id int NOT NULL ,
my_project_description text NOT NULL ,
my_project_deadline datetime NOT NULL ,
PRIMARY KEY  (`my_project_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8

instead.

Comments

0

Table name and column names should not be enclosed with single or double quotes. you can use backticks `

Comments

0

Single quotes denote a string value in MySQL. If you want to quote table names, you have to use a backtick:

CREATE TABLE IF NOT EXISTS `wp_gom_my_project` (
  `my_project_id` int NOT NULL auto_increment,
  `my_project_name` text NOT NULL ,
  `user_id` int NOT NULL ,
  `my_project_description` text NOT NULL ,
  `my_project_deadline` datetime NOT NULL ,
  PRIMARY KEY  (`my_project_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8

Comments

0

Use `(back quote) instead of '(apostrophe) when difining column and table names

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.