Jump to content

mysql_num_rows warning !


Nuv

Recommended Posts

I am getting the following warning with the code below.Can someone please point me why the warning ?

 

Warning

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/r.php on line 500

 

Code

 

  $sql = "SELECT * FROM funeral WHERE name='".$name."' AND phone='".$phone."'";
          $result = mysql_query($sql);
          if((mysql_num_rows($result)) == 0)
          {
            $insertsql = "INSERT INTO funeral (name, street, city, shrtstate, state, pincode, phone) VALUES ('".$name."', '".$street."', '".$city."', '".$shrtstate."', '".$state."', '".$pincode."', '".$phone."')";
            $insert = mysql_query($insertsql);
             
          } 

Link to comment
Share on other sites

If you search for that error message, you will find that it generally means that your query failed due to an error of some kind and you need to (always) have some error checking and error reporting logic in your code to get it to tell you why the query failed.

 

For troubleshooting purposes, you can echo mysql_error() on the next line after the line with your mysql_query() statement to find out why the query is failing.

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.