MidOhioIT Posted January 10, 2010 Share Posted January 10, 2010 This may be simple I just may need another pair of eyes.. When i get records back the below code works just fine, when I get 0 rows back it shows the warning below. As you can see I tried to code for it and you can see that the code works as it echo's my message but I want the warning to go away Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in show_coupon_list.php on line 224 No Coupons for this Catogory or Business. Please let us know about the Category that displayed no results so we can contact businesses for you! $cat_coupons = mysql_query("SELECT a.business_name, a.seq_id, a.state, a.city FROM users a where a.seq_id = '$cat_coupons_seq_id'"); $cat_num=mysql_num_rows($cat_coupons); if ($cat_num > 0) { while ($row = mysql_fetch_array($cat_coupons)) { $business_name = $row["business_name"]; $business_id = $row["seq_id"]; $state = $row["state"]; $city = $row["city"]; echo"<tr> <td align = 'left'> <a href=show_coupon.php?business=".urlencode($business_name).">$business_name $city,$state </a></td> </tr>"; } } else echo"<tr> <td>No Coupons for this Catogory or Business. Please let us know about the Category that displayed no results so we can contact businesses for you! </td> </tr>"; Quote Link to comment Share on other sites More sharing options...
Mchl Posted January 10, 2010 Share Posted January 10, 2010 Most likely there's an error in your query. Use mysql_error to retrieve error message. Quote Link to comment Share on other sites More sharing options...
MidOhioIT Posted January 10, 2010 Author Share Posted January 10, 2010 I was thinking of that but if there was an error wouldnt it show up when I get a valid record back also? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 10, 2010 Share Posted January 10, 2010 The error you are getting means that your query failed to execute. Echo mysql_error() to find out why. A query that executes but returns zero rows DOES NOT produce any mysql_ function errors (unless you have the misfortune of using mysql_result()). Quote Link to comment Share on other sites More sharing options...
MidOhioIT Posted January 10, 2010 Author Share Posted January 10, 2010 that makes since, thank you! I had to move where im doing the count to where im doing the sql since there are some instances that the sql will not run as it depends on a record set back from another sql first. I am not getting the errors now, thank you both... 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.