rubing Posted August 21, 2008 Share Posted August 21, 2008 I am trying to code a script that stops running when there are no results found in my table. When i run this it says that the result set is 0, but it keeps executing. $count =1; while ($count=1) { $api=mt_rand(10000000,99999999); $query="SELECT * FROM api WHERE api=".$api.""; if ($results=$conn->query($query)) { $row_cnt = $results->num_rows; printf("Result set has %d rows.\n", $row_cnt); if($row_cnt==0) { $count=0; } $results->close(); } Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 21, 2008 Share Posted August 21, 2008 This is attempting to ASSIGN a value of 1 to the variable $count and, if successful, returns true. while ($count=1) This does a COMPARISON of $count to see if it is equal to 1, and returns true if it is. while ($count==1) Quote Link to comment Share on other sites More sharing options...
rubing Posted August 22, 2008 Author Share Posted August 22, 2008 Gee, that was dumb of me. Thanks for spottin that one! 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.