I have a MySql query, and I am trying to check if there was a duplicate entry in my PHP code, and I am trying to do something like this:
if(!$result)
{
$error_message = mysql_error();
$pos = strpos ( $error_message , 'Duplicate entry' );
if($pos === false)
{
... Do some error reporting...
but the line $error_message = mysql_error(); seems to be breaking it. Would someone know why that happens and how to detect a duplicate error message correctly since this is a bit of a hack on my part?
mysql_xxx()functions that you're using here are considered obsolete, and are not recommended for use. The PHP manual strongly recommends using either the `mysqli_xxx() functions (which are very similar, but newer and supports more features), or the PDO library (which is quite different but a lot more powerful).iall over, but it's not far off, at the basic level.SELECTfirst on a locked table, then theINSERT, inside a transaction.