Re: DB and INSERT's allready exists?

From: Date: Wed, 13 Jul 2005 09:53:05 +0000
Subject: Re: DB and INSERT's allready exists?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19962@lists.php.net to get a copy of this message
The easy way is... first do a SELECT to see if there is a match before trying to insert. I assume you're using DB? Then you might also be able to check for the error on insert and look at the error code and based on the error do what you want. However, trying to insert bad info into the database isn't very wise, imho. I'd anyway first do the select :) hth, Klaus On 7/13/2005 10:10 AM, Martin Klaffenboeck spake the following words: >Hello! > >I'm using an insert statement to register new users. Now I set a mysql >'Email' field unique so that an user cannot register twice. > >But how can I check if the INSERT failed because of an unique? I want >to tell the user he's allready registerd and ask to send a new password. > >How can I do that? > >thanks, >Martin > > >

« previous php.pear.general (#19962) next »