Jump to content


Photo

Update Query Syntax


  • Please log in to reply
3 replies to this topic

#1 SacredProductions

SacredProductions
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 01 July 2006 - 03:58 AM

I am using this simple query to update the order of some articles on a webpage.

$sql="UPDATE articles_level0 SET order='$norder' WHERE id='$id'";
mysql_query($sql) or die(mysql_error());


I get this error-
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='1' WHERE id='9'' at line 1

The numbers for order and id are correct. I cannot find the syntax error though.

Any help is appreciated

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 01 July 2006 - 12:34 PM

order is a reserved word. Use ... SET `order` = ....
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 SacredProductions

SacredProductions
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 01 July 2006 - 05:54 PM

Whoops.

Thanks a bunch.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 July 2006 - 05:16 AM

Better yet, rename your column... backticks will get you into lots of trouble.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users