Re: help with checking for a duplicate name in db

From: Date: Mon, 13 Nov 2000 20:32:23 +0000
Subject: Re: help with checking for a duplicate name in db
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25025@lists.php.net to get a copy of this message
try this: <? function username_exists($username){ $result=mysql_query("select username from table where username='".$username."'"); return mysql_num_rows($result); } if(username_exists("billybob")){ echo "that name is taken!"; } else { // do stuff } ?> - Mark ?>On Mon, 13 Nov 2000 14:54:39 -0500, Jon Rosenberg (php@columbusinteractive.com) wrote: >I am using mysql to store information for a personals program I'm >writing >(that's how I'm teaching myself PHP) I've come to an impasse, >though. I >need to be able to check and see if a username already exists, so >they are >always kept unique. Here is my code I'm trying use, but am not >getting it >to work. I've tried it about 10 diferent variations of this >code...but >i'm ready for help now! I know I shouldn't be using the db as root, >but I'm >planning on changing that way before I release this. Thanks for any >ideas! > >working script: http://www.politics2004.com/personals >source: http://www.politics2004.com/personals/register.phps > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list- >admin@lists.php.net

« previous php.general (#25025) next »