smartin1017 Posted March 16, 2009 Share Posted March 16, 2009 Hi guys, I have a small block of php that is suppose to check to see if a debate is over and if it is it its suppose to update the winners wins fied and loses loss field. It seems to update the losers loss field but not the winnners. I went in and did a pure sql command in the phpadmin section and it updates the fiend but it doesnt work in this block of code. Please bare with me i am still learning so there are some redundant things in here. Also, I took everything out of this and just ran the first update in each else block to see if the wins filed would be updated and it wasnt. I also took the variables out and put in numbers and it still didnt update the winners wins field. Any help would be greatly appreciated. Heres the code.... $debateid=$_GET['debateid']; $resultxxx= mysql_query("SELECT * FROM debate WHERE thread='$debateid'"); $rowxxx = mysql_fetch_array($resultxxx); $timsss=time(); if ($timsss>$rowxxx['timeend'] && $rowxxx['status']==0) { $end="true"; $pmwid=$rowxxx['pmwid']; $chalid=$rowxxx['chalid']; $threadd=$rowxxx['thread']; if ($rowxxx['pmwvotes']>$rowxxx['chalvotes']) { $winner=$pmwid; $loser=$chalid; $resultw= mysql_query("SELECT * FROM users WHERE id='$winner'"); $roww = mysql_fetch_array($resultw); $winnerinc=$roww['wins']; $winnerinc++; $query4="UPDATE users SET wins='15' WHERE id='$winner'"; $resultl= mysql_query("SELECT * FROM users WHERE id='$loser'"); $rowl = mysql_fetch_array($resultl); $loserinc=$rowl['losses']; $loserinc++; $query5="UPDATE users SET losses='27' WHERE id='$loser'"; if(!mysql_query($query5)){die(mysql_error());} } elseif ($rowxxx['chalvotes']>$rowxxx['pmwvotes']) { $winner=$chalid; $loser=$pmwid; $resultw= mysql_query("SELECT * FROM users WHERE id='$winner'"); $roww = mysql_fetch_array($resultw); $winnerinc=$roww['wins']; $winnerinc++; $query4="UPDATE users SET wins='$winnerinc' WHERE id='$winner'"; $resultl= mysql_query("SELECT * FROM users WHERE id='$loser'"); $rowl = mysql_fetch_array($resultl); $loserinc=$rowl['losses']; $loserinc++; $query5="UPDATE users SET losses='$loserinc' WHERE id='$loser'"; if(!mysql_query($query5)){die(mysql_error());} } else { $winner="tie"; $resultw= mysql_query("SELECT * FROM users WHERE id='$winner'"); $roww = mysql_fetch_array($resultw); $tie=$roww['ties']; $tie++; $query4="UPDATE users SET ties='$tie' WHERE id='$winner'"; $resultl= mysql_query("SELECT * FROM users WHERE id='$loser'"); $rowl = mysql_fetch_array($resultl); $tiel=$rowl['ties']; $tiel++; $query5="UPDATE users SET ties='$tiel' WHERE id='$loser'"; if(!mysql_query($query5)){die(mysql_error());} } $query2="UPDATE debate SET status=1, winner=$winner WHERE thread='$threadd'"; if(!mysql_query($query2)){die(mysql_error());} } Link to comment https://forums.phpfreaks.com/topic/149656-cannot-figure-out-this-error-involving-update/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.