By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

error in your SQL syntax

P: 1
hey i'm try to creat a new table $sql = "CREATE TABLE web.chat (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
from VARCHAR(255) NOT NULL DEFAULT '',
to VARCHAR(255) NOT NULL DEFAULT '',
message TEXT NOT NULL,
sent DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
recd INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)
ENGINE = InnoDB ;

";
and i get this error: check the manual that corresponds to your MySQL server version for the right syntax to use near 'from VARCHAR(255) NOT NULL DEFAULT '', to VARCHAR(255) NOT NULL DEFAULT '', ' at line 3
if i change "from" and "to" to another names it work but i need to keep this names.
thanks..
Mar 8 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,347
Those are reserved key words. Why do they HAVE to be named that?

If you absolutely must, just qualify it as a field using the appropriate demarcation for whatever database you're using (it's different from database to database, look it up).

But it is strongly recommended that you change the name because it will and already has caused problems.
Mar 8 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.