In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Jason Bell") wrote:

> Hello! I'm writing a script that validates a form.... It creates users in a
> mysql table, where there are 2 unique columns 'username' and 'email'.
> I'm putting mysql_error() into a variable, but I don't want the end user to
> see that particular message... is there a way to look at just the key that
> has been duplicated, and create a custom error message for user display?
> for example, when I duplicate a username, 'jbell', I get this from
> mysql_error() : "Duplicate entry 'jbell' for key 2"
> I want to be able to see that the error is from key 2, and react
> accordingly....

>From a MySQL perspective, you could adjust the query so no error is 
generated.  See the syntax for "INSERT IGNORE" or "REPLACE" for instance.

>From a PHP perspective, there are functions such as set_error_handler() or 
register_shutdown_function() to deal with such issues.



PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to