Hi; PHP experts:
In the last part of my project I run into a trouble in using mysql_num_rows() function, I want to use this function to check if the userID entered by the new user is already taken in the database. Here is the code:
$user_name = "root";
$pass_word = "";
$database = "memberbook";
$server = "127.0.0.1";
$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$num_rows = 0;
//====================================================================
// CHECK THAT THE USERID IS NOT TAKEN from the member table
//====================================================================
$SQL = "SELECT * FROM memberbook WHERE userid = $userid";
$result = mysql_query($SQL);
$num_rows = mysql_num_rows($result);
}
The message is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\PHP\www\signup.php on line 143
I can not see anything wrong in the codes, but it never works.
Your help is highly appreciated.
Peter
In the last part of my project I run into a trouble in using mysql_num_rows() function, I want to use this function to check if the userID entered by the new user is already taken in the database. Here is the code:
$user_name = "root";
$pass_word = "";
$database = "memberbook";
$server = "127.0.0.1";
$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$num_rows = 0;
//====================================================================
// CHECK THAT THE USERID IS NOT TAKEN from the member table
//====================================================================
$SQL = "SELECT * FROM memberbook WHERE userid = $userid";
$result = mysql_query($SQL);
$num_rows = mysql_num_rows($result);
}
The message is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\PHP\www\signup.php on line 143
I can not see anything wrong in the codes, but it never works.
Your help is highly appreciated.
Peter