# Ugh, supplied argument is not a valid MySQL result!

**URL:** <https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541>\
**Category:** programming\
**Created:** [April 22, 2006, 3:45am UTC](https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541 "2006-04-22T03:45:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [April 22, 2006, 3:45am UTC](https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541/1 "2006-04-22T03:45:36Z")

</div>

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:

> [@Stupid MySQL error](#):
>
> Warning: mysql\_num\_rows(): supplied argument is not a valid MySQL result resource **Line 57**

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)

```auto

<?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';
}

```

---

<div class="post-metadata">

**Author:** ![signifer123](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@signifer123](https://forum.kirupa.com/u/signifer123)\
**Post date:** [April 22, 2006, 8:40am UTC](https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541/2 "2006-04-22T08:40:43Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [April 22, 2006, 3:19pm UTC](https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541/3 "2006-04-22T15:19:41Z")

</div>

GOod call i’ll try that out hang on

---

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [April 22, 2006, 3:23pm UTC](https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541/4 "2006-04-22T15:23:19Z")

</div>

Man I feel silly I was querying user\_name where my column was user\_id lol  
thanks man, works fine now

---

<div class="post-metadata">

**Author:** ![Seb\_Hughes](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Seb\_Hughes](https://forum.kirupa.com/u/Seb_Hughes)\
**Post date:** [April 22, 2006, 3:38pm UTC](https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541/5 "2006-04-22T15:38:02Z")

</div>

That code is form a tutorial on phpfreaks

---

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [April 22, 2006, 10:05pm UTC](https://forum.kirupa.com/t/ugh-supplied-argument-is-not-a-valid-mysql-result/186541/6 "2006-04-22T22:05:55Z")

</div>

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
