kaozdragon Posted March 6, 2007 Share Posted March 6, 2007 $result = mysql_query("SELECT * FROM signup"); $row = mysql_fetch_array($result); $increase = mysql_query("UPDATE signup SET hot = hot+1 "); $username = $_COOKIE['username']; $adduser = mysql_query("UPDATE signup SET hotname ='$username'"); $adduser2 = mysql_query("UPDATE signup SET hotname2 ='testing2'"); if ($row['hot']==0) { $increase; $adduser; echo "User has been increased to " . $row['hot'] . " and the user, " . $row['hotname'] . " has been added. <a href='signup.php'>Signup again</a>"; mysql_close($con); } elseif ($row['hot']==1) { $increase; $adduser2; echo "User is now at " . $row['hot'] . " and the user " .$row['hotname2'] . "has been added. <a href='signup.php'>Go back</a>"; mysql_close($con); } else { echo "full up, sorry."; } for some reason, even when $row['hot'] is set to 0 in the table, it will add both adduser and adduser2. any help would be appreciated, thanks. Quote Link to comment Share on other sites More sharing options...
btherl Posted March 6, 2007 Share Posted March 6, 2007 kaoz, you have a misconception about how variables work. This code actually executes the query, storing the result in $adduser $adduser = mysql_query("UPDATE signup SET hotname ='$username'"); Later when you write "$adduser;", that does nothing at all. The query was already executed. So to fix it, you just need to move those mysql_query() calls inside the if/else All 3 queries should go inside, replacing "$increase;", "$adduser;" and "$adduser2" Quote Link to comment Share on other sites More sharing options...
kaozdragon Posted March 6, 2007 Author Share Posted March 6, 2007 thanks =.= i just started with php a couple days ago....trying to finish this IT project. Quote Link to comment Share on other sites More sharing options...
btherl Posted March 6, 2007 Share Posted March 6, 2007 Good luck You've come to the right place for help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.