This is the error message I received:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in signup_ck.php on line 40

I am trying to teach myself to use PHP and MySQL together. I have a site that needs a special area that should have a login, so I found a set of scripts, and started playing with the code. Now I get an error message. This is the file listed in the error message.

I know this is not nice code, but the scripts I found were using HTML3 and I tried to clean things up using HTML5 and CSS.

Any guidance will be welcome.

Code MySQL:
<?php
 
include "include/db_login.php";// database connection details stored here
// Collect the data from post method of form submission // 
$userid=$_POST['userid'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$todo=$_POST['todo'];
$email=$_POST['email'];
$name_last=$_POST['name_last'];
$name_first=$_POST['name_first'];
 
?>
<!doctype html>
<html>
 
<head>
<meta charset="UTF-8">
<title>Check Signup Data</title>
</head>
 
<body >
 
<?php
if(isset($todo) and $todo=="post"){
 
$status = "OK";
$msg="";
 
// if userid is less than 5 char then status is not ok
if(!isset($userid) or strlen($userid) <5){
$msg=$msg."User id should be 5 or more than 5 char length<br>";
$status= "NOTOK";}					
 
if(!ctype_alnum($userid)){
$msg=$msg."User id should contain alphanumeric characters only<br>";
$status= "NOTOK";}					
 
 
if(mysql_num_rows(mysql_query("SELECT userid FROM member_tbl WHERE userid = '$userid'"))){
$msg=$msg."Userid already assigned. Please select another userid.<br>";
$status= "NOTOK";}					
 
 
if ( strlen($password) <8 ){
$msg=$msg."Password must be 8 or more than 8 char length<br>";
$status= "NOTOK";}					
 
if ( $password <> $password2 ){
$msg=$msg."Both passwords do not match.<br>";
$status= "NOTOK";}					
 
 
if($status<>"OK"){ 
echo "$msg<br><input type='button' value='Retry' onClick='history.go(-1)'>";
}else{ // if all validations are passed.
$query=mysql_query("insert into member(userid,password,email,name_last,name_first) values('$userid','$password','$email','$name_last','$name_first')");
echo "Welcome, You have successfully submitted new member information<br><br><a href=login.php>Click here to login</a><br>";
}
}
?>
 
</body>
 
</html>