views:

20

answers:

1

Hello,

Is there a way that I can check for specific errors in MySQL with PHP? For example, I want to run a query that inserts 1000 last names into a database table. I know that I can use mysql_error() to check for errors, but I want to check specifically for a "duplicate value" error. Is there anyway to do that?

Thanks!

+2  A: 

You could compare the error message. There is also mysql_errno(): http://www.php.net/manual/en/function.mysql-errno.php. You could find the exact error num for Duplicate Value from the MySQL spec for a better comparison.

Jason McCreary
Perfect, thanks!
behrk2