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:
include "include/db_login.php";// database connection details stored here
// Collect the data from post method of form submission // 
<!doctype html>
<meta charset="UTF-8">
<title>Check Signup Data</title>
<body >
if(isset($todo) and $todo=="post"){
$status = "OK";
// 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";}					
$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";}					
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>";