0

Well, whenever I try to run a user verify script, that asks SQL if a username is not taken, I always get this response...

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in dir/userver.inc on line 11
count unavailable

this is the code in general:

<?php
//User Name Verify

function userver($userveri)
{

    $query = "SELECT 'username' FROM 'users' WHERE 'username'='$userver1'";

    $sql = mysql_query($query);

    $nrows = mysql_num_rows($sql) or die("count unavailable");



    if($nrows != 0)
    {
    echo "The username you have chosen already exists!";
    die();
    } 
    else 
    {
    return($userveri);
    }

}
?>

Anyone have some ideas? I really need this function for the user database to function correctly. Help is appreciated.

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by GliderPilot
0

The problem is not with your num_rows line it is with your query line. The variable name you search with does not match the variable name you passed to the function.

variable passed to function is --> $userveri
Varibale passed to the query --> $userver1

Change the 1 to an i and this should work for you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.