error in your SQL syntax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tom hin
    New Member
    • Mar 2012
    • 1

    error in your SQL syntax

    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..
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    Working...