[PHP] Re: check if user exists

2001-08-01 Thread Richard Lynch

> how do i check if user exist?
> I tried...
> $result = mysql_query("SELECT count(uname) FROM users WHERE
> uname=\'$username@$domain\'");

Get rid of the \ there.  You are inside a ", not a ', and the \ is wrong.

Also, add some error checking like:

if (!$result){
echo "MySQL error ", mysql_error(), "\n";
}

Actually, don't write it to the screen for users to see on a production box,
but log it somewhere you can get it.

> if(isSet($result))
> return("Username already exists.\n");
> but still wont work.. :(

$result will always be set.  You just set it.

You need to do something like:

if (mysql_result($result, 0, 0) == 1){
echo "Username already exists.\n";
}

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: check if user exists

2001-08-01 Thread Fredrik Arild Takle


$result = mysql_query("SELECT uname FROM users WHERE
uname=\'$username@$domain\'");
$numrows = mysql_num_rows($result);

if ($numrows == '1') {
  echo "User already exists";
} else {
  echo "User don't exist";
}

Best Regards
Fredrik A. Takle
Bergen, Norway

"Ker Ruben Ramos" <[EMAIL PROTECTED]> wrote in message
009f01c11aba$1110d6c0$323039ca@weblinq1">news:009f01c11aba$1110d6c0$323039ca@weblinq1...
> how do i check if user exist?
> I tried...
> $result = mysql_query("SELECT count(uname) FROM users WHERE
> uname=\'$username@$domain\'");
> if(isSet($result))
> return("Username already exists.\n");
> but still wont work.. :(
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]