weird (to me) error in simple mysql query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hanzo
Forum Newbie
Posts: 16
Joined: Thu Nov 17, 2005 10:14 am

weird (to me) error in simple mysql query

Post by hanzo »

Code: Select all

<?
mysql_connect ('XXremovedXX','XXremovedXX','XXremovedXX')or die('Could not connect: ' . mysql_error());
mysql_select_db ('XXremovedXX');
$query0 = "UPDATE users SET order='2' WHERE email = 'emailertje@gmail.com'";
mysql_query ($query0) or die(mysql_error());
?>

gives me:
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='2' WHERE email = 'emailertje@gmail.com'' at line 1
And I really haven't got any idea what I'm doing wrong :cry:


Thanks
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

for all intents and purposes, that should work.

what are the field types on the db?

edit: as an aside, you should always escape your string vars with mysql_real_escape_string()
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

order is a reserved word.. use backticks ;)

Code: Select all

$query0 = "UPDATE `users` SET `order`='2' WHERE `email` = 'emailertje@gmail.com'";
hanzo
Forum Newbie
Posts: 16
Joined: Thu Nov 17, 2005 10:14 am

Post by hanzo »

Jcart wrote:order is a reserved word.. use backticks ;)

Code: Select all

$query0 = "UPDATE `users` SET `order`='2' WHERE `email` = 'emailertje@gmail.com'";
never could figer out that myself. thanks :!:
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Jcart wrote:order is a reserved word.. use backticks ;)

Code: Select all

$query0 = "UPDATE `users` SET `order`='2' WHERE `email` = 'emailertje@gmail.com'";
yeah or that 8O
Post Reply