emma57573 Posted August 5, 2008 Share Posted August 5, 2008 In trying to enter the word 'closed' in the status field in my_table if the quantity field = 0 Now this statement is entering the word 'closed' no matter if the quantity is 0 or 5! Im not sure where im going wrong Ive tried =="0" =='0' and It then stops entering the word altogether. $srt=mysql_query("SELECT * FROM my_table WHERE id=$id"); if ($srt["quantity"]==0){ $sql= "UPDATE my_table SET status='closed' WHERE id=$id"; mysql_query($sql); } Link to comment https://forums.phpfreaks.com/topic/118216-solved-whats-wrong-with-this-query/ Share on other sites More sharing options...
asmith Posted August 5, 2008 Share Posted August 5, 2008 you need to post more code here. what is this $strl["quantity"]? Link to comment https://forums.phpfreaks.com/topic/118216-solved-whats-wrong-with-this-query/#findComment-608379 Share on other sites More sharing options...
emma57573 Posted August 5, 2008 Author Share Posted August 5, 2008 sorry I changed my values before I posted and made a typo its meant to be $srt["quantity"] Link to comment https://forums.phpfreaks.com/topic/118216-solved-whats-wrong-with-this-query/#findComment-608384 Share on other sites More sharing options...
asmith Posted August 5, 2008 Share Posted August 5, 2008 why you haven't fetch the query ? $srt=mysql_query("SELECT * FROM my_table WHERE id=$id"); $result = mysql_fetch_array($srt); if ($result["quantity"]==0){ $sql= "UPDATE my_table SET status='closed' WHERE id=$id"; mysql_query($sql); } Link to comment https://forums.phpfreaks.com/topic/118216-solved-whats-wrong-with-this-query/#findComment-608390 Share on other sites More sharing options...
emma57573 Posted August 5, 2008 Author Share Posted August 5, 2008 aw ok that explains why it was always reading '0' Im still novice so Im still making silly mistakes. thanks for your help Link to comment https://forums.phpfreaks.com/topic/118216-solved-whats-wrong-with-this-query/#findComment-608399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.