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
https://forums.phpfreaks.com/topic/233462-mysql_num_rows-warning/
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.

Archived

This topic is now archived and is closed to further replies.

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