Jump to content

[SOLVED] My SQL num_row help


jaku78

Recommended Posts

I'm having trouble with this user verify script I made. And I know it's the SQL getting confused, whether it is the variable set-up I don't know. This is just a included file, and in the index file, it's already connected to the database, and there is no errors with that because the error is:

 

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

count unavailable

 

And count unavailable is apart of one of my SQL function error messages.

 

<?php
//User Name Verify

function userver($userveri)
{

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

$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);
}

}
?>

 

Help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/45147-solved-my-sql-num_row-help/
Share on other sites

<?php
//User Name Verify

function userver ( $userveri )
{

$query = "SELECT username FROM users WHERE username = '$userveri'";
$sql = mysql_query($query);
if(mysql_num_rows($sql) > 0)
{
echo "The username you have chosen already exists!";
die();
} 
else 
{
return $userveri;
}

}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.