I have this error in my webpage.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like ''' at line 1
However, I want to ignore this error because it does not influence my output. Therefore, I want to hide this error from displaying on user side.
I tried to use this code error_reporting(E_ALL ^ E_NOTICE);
to hide this error, but only can hide "notice" error.
Any suggestion / solution to hide above error?
Theoretically, You can use "@" sign before function call to prevent from showing any errors. Example,
$result = @$mysqli->query($query);
But I would strongly suggest fixing that error.
As everyone suggested, ignoring errors is bad practice; it will hinder your project when new requirements will be implemented etc. or when you (or your replacement) will debug it 6 months from now...
alter code so if user did not enter data, the query is not processed eg:
if($_POST) mysql_query($query,$conn);
also, I always ensure that actual error messages NEVER DISPLAY, I show a random string i can look up in my code, so if it ever shows, it does not disclose any database information to potential hackers.
$result = mysql_query($query,$conn) or die("HYGTR564dfREFH");