Database Error

edited July 2011 in Modules
I'm getting this error when I create a new category through the admin.
Any ideas as to what I could be doing wrong?
A bug, perhaps?


A Database Error Occurred

Error Number: 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 'order, section, link) VALUES ('', 'Test', '', 'yes', '', 'News', '') ON DUPLICAT' at line 1

INSERT IGNORE INTO categories (id, name, description, published, order, section, link) VALUES ('', 'Test', '', 'yes', '', 'News', '') ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id), name = VALUES(name), description = VALUES(description), published = VALUES(published), order = VALUES(order), section = VALUES(section), link = VALUES(link)

Filename: core/MY_DB_mysql_driver.php

Line Number: 265

Comments

  • edited 11:57AM
    What version of MySQL are you running?
  • edited 11:57AM
    MySQL 5.5.9 running locally via MAMP.
  • edited July 2011
    Is there anything that you can see that may be wrong with this query like perhaps. What happens if you run this query outside of PHP (in phpMyAdmin or other MySQL management app):
    INSERT IGNORE INTO categories (id, name, description, published, order, section, link) VALUES ('', 'Test', '', 'yes', '', 'News', '') ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id), name = VALUES(name), description = VALUES(description), published = VALUES(published), order = VALUES(order), section = VALUES(section), link = VALUES(link)
  • edited 11:57AM
    Excellent, thanks.

    I threw that query into SQLpro and got the same error.
    I had someone else come by and put another set of eyes on it, and it was the use of the word 'order', which is a reserved word in SQL, that was causing the problem.

    I changed the name of the column and the query ran fine.

    So, problem solved!
Sign In or Register to comment.