Jump to content

Warning: mysql_num_rows() supplied argument is not a valid MySQL result resource


MidOhioIT

Recommended Posts

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>";

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.