The-Last-Escape Posted May 2, 2007 Share Posted May 2, 2007 i have been messing with my php script trying to get it to work. before trowing my monitor out of the window i thought maybe you guys know what is going on:) its a small piece of script from a forum. this peace of code delete's a complete topic from my forum and will also set the total number of replys back. lets say my counter is on 15 for the amount of replys that are on my forum. then when i delete a topic with only 5 replys in it, i want the counter to go back to 10. so i wrote this script. $quik =mysql_query("SELECT * FROM forumnews WHERE vantopicid = '$topic_id' ") or die(mysql_error()); $ab =mysql_num_rows($quik); if (($ab = 1) OR ($ab = 0)){ }else{ mysql_query("UPDATE forums SET nrofreplys = nrofreplys-'$ab' WHERE forum_id = '$vfi' ") or die(mysql_error()); } the damn thing just wont work, anybody have an idea??? thanks in advance Link to comment https://forums.phpfreaks.com/topic/49694-query-help/ Share on other sites More sharing options...
paul2463 Posted May 2, 2007 Share Posted May 2, 2007 try this <?php $quik =mysql_query("SELECT * FROM forumnews WHERE vantopicid = '$topic_id' ") or die(mysql_error()); $ab =mysql_num_rows($quik); if (($ab != 1) OR ($ab != 0)){ mysql_query("UPDATE forums SET nrofreplys = nrofreplys-'$ab' WHERE forum_id = '$vfi' ") or die(mysql_error()); } ?> your code sais that if its true do nothing , so why not tell it if its NOT true then do something, and the fault with your code was to do with = signs a = b assigns a with the value of b a == b checks to see if a is equal to b you were assigning variables not checking them and where is $vfi assigned??? another way <?php $quik =mysql_query("SELECT * FROM forumnews WHERE vantopicid = '$topic_id' ") or die(mysql_error()); $ab =mysql_num_rows($quik); if ($ab > 1){ mysql_query("UPDATE forums SET nrofreplys = nrofreplys-'$ab' WHERE forum_id = '$vfi' ") or die(mysql_error()); } ?> Link to comment https://forums.phpfreaks.com/topic/49694-query-help/#findComment-243643 Share on other sites More sharing options...
Nameless12 Posted May 2, 2007 Share Posted May 2, 2007 - Link to comment https://forums.phpfreaks.com/topic/49694-query-help/#findComment-243644 Share on other sites More sharing options...
The-Last-Escape Posted May 2, 2007 Author Share Posted May 2, 2007 Cheers guys very helpful keep it up Link to comment https://forums.phpfreaks.com/topic/49694-query-help/#findComment-243647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.