This is the code I currently have and it give me an error:
PHP Code:
$userid=sanitizeFromPost('userid');
if (strlen($userid)<5) {
$msg .= 'User ID should be 5 or more than 5 char length.<br>';
}
if (mysql_num_rows(mysql_query("SELECT user_id FROM member_tbl WHERE user_id = '$userid'"))) {
$msg .= 'Userid already assigned. Please select another userid.<br>';
}
if (!$result = mysql_query($sql)) {
//There was an error in our query and it returned FALSE.
echo mysql_error();
} elseif(mysql_num_rows($result) == 0) {
//The query executed successfully (it returned a Result Resource), but had no results to return.
} else {
//The query both executed successfully, and returned at least 1 row of data.
}
The error is:
Notice: Undefined variable: sql inmember_info_ck.php on line 55
Line 55 is: if (!$result = mysql_query($sql)) {
So do I need to put in a line that reads:
$sql = (mysql_num_rows(mysql_query("SELECT user_id FROM member_tbl WHERE user_id = '$userid'")
And then change my query to be:
if ($sql) {
Bookmarks