How to avoid to display this error in PHP?

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 IGNORE keyword in your query

INSERT IGNORE INTO ...

Quite ironically, you actually should remove the die() statement, but only to replace it with way more reliable and safe trigger_error(), so, the code should be

$result = mysql_query($query) or trigger_error(mysql_error()." in ".$query);

Leave a Comment