Re: check if user exists
| From: | Richard Lynch | Date: | Wed, 01 Aug 2001 20:29:21 +0000 |
| Subject: | Re: check if user exists | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-60809@lists.php.net to get a copy of this message | ||
> 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(), "<BR>\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.<br>\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.<BR>\n";
}
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
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