By default, mysqli throws PHP warnings for errors. This is not ideal, especially in your situation where you want to see errors but do not want the sensitive information about your database displayed on the screen.
What I recommend is that you change the report mode of mysqli to throw Exceptions instead - this way you can catch them and then handle and log. My example below shows how you might do that:
mysqli_report(MYSQLI_REPORT_STRICT);
try {
$DBconn = new mysqli($DBhost, $DBuser, $DBpass, $DBname, $DBport);
} catch (Exception $e) {
error_log(
"Connect Error! ".$e->getMessage()."\n",
3,
"/home/www/host/PHP_errors.log"
);
}
If you're not a fan of exceptions - then you can disable reporting of PHP warnings by changing your error_reporting
declaration to exclude them like this:
error_reporting(E_ALL ^ E_WARNING);
But this will disable reporting of all warnings - not just those from mysqli.