Reputation: 4496
I have this problem but I just found out the solution so I'll write it here anyway in case anyone stumbles in it. This is my mysql query:
mysql_query("SELECT id FROM order ORDER BY id DESC LIMIT 1")
And the error I received was
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 ORDER BY id DESC LIMIT 1' at line 1
Upvotes: 2
Views: 2418
Reputation: 28403
Order is reserved Word. You have to use like Enclose ORDER in back-ticks.
Try this
mysql_query("SELECT id FROM `order` ORDER BY id DESC LIMIT 1")
Upvotes: 3