Jump to content

UPDATE statement acting crazy


marvelous_mogli

Recommended Posts

Hi,

There are a few UPDATE statements which are not executing or executing erronously with mysql_query().

When tried using SQLYog or other client applications the queries works fine.

 

Environment 1:

MySQL: 4.1.9-max

PHP: 4.3.10

Client API version:  3.23.49

 

Environment 2:

MySQL: 4.1.21

PHP: 4.4.4

Client API version:  4.1.21

 

 

Query 1:

update order_master set order_status = '2', order_state_date_change = now() where order_id = 18

 

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 '' at line 1

 

 

Query 2:

Trying to increment a field by 1 but it increments by 3

Link to comment
Share on other sites

Hi!

 

Try this:

<?php
$sql = ("UPDATE order_master SET order_status='2', order_state_date_change=now() WHERE order_id='18'");
$rs_update = mysql_query($sql);
?>

 

By the way, (I'm sure you already know this) if the auto-increment is set in the database, you don't have to specify it in this query, it will increment by 1 each time a new row of data is added to the database. So if order_status is your incrementing field, you don't have to specify it here.

 

That '2' might be the reason it increases by 3 instead of 1 as you said originally.

 

Hope it helps,

Regards,

Iceman

Link to comment
Share on other sites

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.