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, and want to be able to detect any errors and handle them.
I know that I can use mysql_error() to check for errors, but I want to specifically check for a duplicate value error only. Is there any way to do that?
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.