Re: duplicated entry for key #

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: duplicated entry for key #
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15080@lists.php.net to get a copy of this message
> >'Duplicate entry 'username' for key 1. This means that you do have a duplicate entry in a row of your DB. Try setting a column as "Auto increment": ALTER TABLE <table_name> id smallint(10) DEFAULT '0' NOT NULL auto_increment (or something like that) This means each set of data you put into the DB will automatically create a new row in which to insert this data. You should really do some basic checking before you do inserts, to ensure you don't have multiple entries: $check = mysql_num_rows($query); if($check != 0) { echo "You have a duplicate entry!"; } Cheers Russ On Mon, 17 Dec 2001 23:40:44 +0100 nautilis <josemsala@hotmail.com> wrote: > Hi everybody! > > My problem is: > > I have a form to allow users in a website to register. My problem is that > when someone registers a name that is alredy taken, mysql returns a > 'Duplicate entry 'username' for key 1. > > I just want to show a message to user telling that the username is in use by > another user and prompting him to choose a new one. > > I am a newbie at php and mysql so any help will be greatly appreciated. > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > #-------------------------------------------------------# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam Room 1C 'The Eastings' East Road, Cambridge e: r.j.michell@apu.ac.uk w: www.apu.ac.uk/webteam www.theruss.com #-------------------------------------------------------#

« previous php.db (#15080) next »