I'm trying to make this code so that if certain fields were not filled in, it would return a message. But my login screen that I am making keeps coming up with an error message: 'Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/lonebyrd/public_html/registration.php on line 83'. I'm thinking it has to do with the mysql_num_rows because that is in every line the errors are in, but I don't know how to fix it.
$nameq = "SELECT name FROM registration WHERE username = '$name' LIMIT 1";
$emailq = "SELECT email FROM registration WHERE email = '$email' LIMIT 1";
//put errors into an array I need to change these if I change the db
$errors = array();
if(empty($name)) {
$errors[] = "The name field was blank! <br />";
}
if(mysql_num_rows(mysql_query($nameq)) > 0) {
$errors[] = "The name given is already in use! Please try another one! <br />";
}
if(empty($email)) {
$errors[] = "The email field was blank! <br />";
}
if(mysql_num_rows(mysql_query($emailq)) > 0) {
$errors[] = "The email given is already in use! Please try another one! <br />";
}
if(mysql_num_rows(mysql_query($nickname))>0) {
$error[] = "That nickname is already taken. Please try another one.<br />";
}
if(empty($password)) {
$errors[] = "The password field was blank! <br />";
}
if(count($errors) > 0) {
foreach($errors as $err) {
echo $err;