Mumlebumle Posted August 18, 2010 Share Posted August 18, 2010 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 More sharing options...
Psycho Posted August 18, 2010 Share Posted August 18, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.