php mysql_connect Warning disable
you can set error reporting error_reporting(0);
to turn off errors and warning for speacific page
just set as per your need
# config.ini
# PHP error reporting. supported values are given below.
# 0 - Turn off all error reporting
# 1 - Running errors
# 2 - Running errors + notices
# 3 - All errors except notices and warnings
# 4 - All errors except notices
# 5 - All errors
Doc
just set at head in page like this
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
?>
let me know if i can help you more.
The proper solution is to disable the displaying of PHP errors, warnings and notices to the user. This can be done via the display_errors
setting in your php.ini configuration file:
display_errors = Off
It can also be set at runtime via ini_set()
:
ini_set('display_errors', '0');
From the Manual:
display_errors
This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.
Doing that would prevent any users from seeing sensitive PHP error messages, but still allow them to be printed to the log file.
Use of the @
suppression method would do what you want but it would still allow any other PHP errors/warnings to be printed to the user, which is a security issue because those errors can contain sensitive information that should not be exposed.
Yes, add an @ sign like so to suppress warning / error messages, then do the error once your own:
$dblink = @mysql_connect(DBHOST_LOCAL, DBUSER, DBPASS);
if (!$dblink)
{
$dblink = @mysql_connect(DBHOST_REMOTE, DBUSER, DBPASS);
}
if (!$dblink)
{
$message = sprintf(
"Could not connect to local or remote database: %s",
mysql_error()
);
trigger_error($message);
return;
}
Take care that you need to handle all error reporting your own then. Such code is hard to debug in case you make a mistake.