I want avoid to display an error when is inserted a duplicate entry in the database.
I have added this “@” but the error is always displayed:
$result = @mysql_query($query) or die("Query failed insert. Mysql error: ".mysql_error() );
output:
Query failed insert. Mysql error: Duplicate entry for key 'url'
How to avoid to show an error when is inserted a duplicate entry ?
Adding this “@” is a most stupid thing a developer can do ever.
You are confusing the error message with the error itself. You have to fix the error, not the message.
To fix this one, you have to use
IGNOREkeyword in your queryQuite ironically, you actually should remove the
die()statement, but only to replace it with way more reliable and safetrigger_error(), so, the code should be