PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm having some issues trying to get a count with "mysql_num_rows". Here's my code and the errors I am getting. (I also tried using the count(*) function but had no luck. Thanks in advance for any help.
//Connecting to the database
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db ("jpobrien");
$result = mysql_query("select first_name_1 from Customers", $db);
$number = mysql_num_rows($result);
$customer_id = $number + 9000;
Here's the error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jpobrien/public_html/staff/customer_new_enter.php on line 56
There was a problem with the database server. Please try again later
It's probably a problem with your query. Adding mysql_error() as zoxive said above will help you figure out what's wrong. You could be trying to select a name that doesn't exist in the database.