I’m attempting to write my first php/mysql page and am running into a SQL syntax error I can’t find the cause of.
The error is as following:
Unable to create domain suggestions table. Error 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 ‘PRIMARY_KEY, domain TEXT, author TEXT, submitdate DATE NOT NULL ) DE’ at line 2
CREATE TABLE domainsuggestions( id INT NOT NULL AUTO_INCREMENT PRIMARY_KEY, domain TEXT, author TEXT, submitdate DATE NOT NULL ) DEFAULT CHARACTER SET utf8
Advertisement
Answer
In your CREATE TABLE statement, it should be PRIMARY KEY
with a space instead of PRIMARY_KEY
that contains an underscore.
Solution:
Remove the underscore from PRIMARY_KEY
.
Corrected script:
CREATE TABLE domainsuggestions ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, domain TEXT, author TEXT, submitdate DATE NOT NULL ) DEFAULT CHARACTER SET utf8
Demo:
Click here to view the working CREATE TABLE script in SQL Fiddle.