Jump to content

Recommended Posts

Hi i have the following code

 

$orderFetch->order="3";
mysql_query("UPDATE `categories` SET order=order-1 WHERE `order` > $orderFetch->order");

 

i wish to minus -1 from all the "order" fields in categories that are over a certain value i.e 3. But however this code is not working can anyone tell me where i'm going wrong?

 

thank you

Add logic to check for query success/failure, and (at least while in development) echo the query string along with mysql_error() on failure. On success check that mysql_affected_rows() is > 0.

`order` is a MySQL reserved word. Either change the name of the field, or enclose `order` in backticks whenever it appears in a query string as a field/table/database name.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.