Jump to content

Recommended Posts

Why doesnt this query work, i does update, thats not the problem, but the "AND reimburse.check = 0";" does not function and just keeps on running the script. It is supposed to be there to give out an error so that if one updates it shortly after another the 2nd one will be aware its already been done.

 

$sql2 = "UPDATE reimburse SET reimburse.check = 1 WHERE reimburse.kill_id = $bursekillid AND reimburse.check = 0";

mysql_query($sql2)or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/211092-php-sql/
Share on other sites

What do you mean it is supposed to give out an error? That query will simply update every record where the conditions exist. If there are no records that match the conditions - then no records are updated. That is not an error. You can either:

 

Do two queries: one to see if the record exists and check the reimburse.check value. Then, if appropriate, do the update query.

 

Or you can do the update query and afterwards check the affected row count. If 0, then you know that either no record exists with that id or the reimburse.check value is already set to 1.

Link to comment
https://forums.phpfreaks.com/topic/211092-php-sql/#findComment-1100854
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.