Monday 6 August 2018

php - MySQL said: Documentation (#1064) - You have an error in your SQL syntax;




I am trying to create a table in my mysql database and I keep getting this error. Please help, code is below:



CREATE TABLE 'Test'.'Sensor' (
'id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
'time' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
'value' VARCHAR( 10 ) NOT NULL,
)


The Error is:




MySQL said: Documentation




#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 ''Test'.'Sensor' ( 'id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
'time' TIMES' at line 1



Answer




Remove the single quotes and try like this:-



CREATE TABLE Test.Sensor ( 
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
value VARCHAR( 10 ) NOT NULL
);

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...