Ugh, supplied argument is not a valid MySQL result!

Ok so im creating a sign up page in PHP using MySQL and this is the error I get when i try and run it:

I’ve searched and searched and have failed to yield any answers on what GIVES that error so that I can try and fix it… any ideas?
here’s the code I’m working on. (Line 57 is commented)


<?php
include 'db.php';

$submitted = $_POST["submitted"];
$errors = false;
if ($submitted == 'true'){
    $username = $_POST["user_name"];
    $firstname = $_POST["first_name"];
    $lastname = $_POST["last_name"];
    $email = $_POST["e_mail"];
    $password = $_POST["password"];
    $conf = $_POST["password_conf"];
    
    $firstname = stripslashes($firstname);
    $lastname = stripslashes($lastname);
    $email = stripslashes($email);
    $username = stripslashes($username); 
    $password = stripslashes($password);
    $conf = stripslashes($conf);
    
    if(!$username || !$firstname || !$lastname || !$email || !$password || !$conf){
        if(!$username){
            echo 'You did not choose a user name, it is required <br/>';
            $errors = true;
        }
        if(!$firstname){
            echo 'You did not enter your first name, it is required <br/>';
            $errors = true;
        }
        if(!$lastname){
            echo 'You did not enter your last name, it is required <br/>';
            $errors = true;
        }
        if(!$email){
            echo 'You did not enter your E-Mail address, it is required <br/>';
            $errors = true;
        }
        if($password == $conf){
            if(!$password){
                echo 'You did not pick a password, please pick one <br/>';
                $errors = true;
            }
            if(!$conf){
                echo 'You did not validate your password, please enter it twice <br/>';
                $errors = true;
            }
        } else {
            echo "Your passwords don't match, try again <br/>";
            $errors = true;
        }
    }
    if($errors == true){
        include "signup.htm";
    } else {
        $sql_username_check = mysql_query("SELECT user_name FROM users WHERE user_name='$username'");
**//----LINE 57--------------------------------------------**
         $username_check = mysql_num_rows($sql_username_check); 
    
        if($username_check > 0){
            echo "The username you have chosen is already in use by someone else, please try a different one";
            unset($username);
            include 'signup.htm';
        }
    }
} else {
    include 'signup.htm';
}



check your mysql query, if it fails it will give false instead of the data you want

running it in phpMyAdmin seem to be the easiest way to check for me :slight_smile:

GOod call i’ll try that out hang on

Man I feel silly I was querying user_name where my column was user_id lol
thanks man, works fine now

That code is form a tutorial on phpfreaks

Someone give seb a medal for showing up lol

Yea i’m using that tutorial for my Web Programming assignment… but it doesnt do what the teacher wants so i have to rewrite pretty much all of it