I have a problem with ini_set(‘display_errors’, ‘off’).
To quickly give you a run-through I have two files in the same folder:
1) “php.ini”, where “display_errors = on” is set.
2) “iniTest.php” which has the following code:
ini_set('display_errors', 'off');
$conn = mysql_connect('localhost','excamplehidden','examplehidden') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('examplehidden',$conn) or trigger_error("SQL", E_USER_ERROR);
mysql_query("SELECT * FROM `FakeTable`") OR die(mysql_error());
ini_set('display_errors', 'on');
When I run this page in a browser I still get:
“Table ‘examplehidden.FakeTable’ doesn’t exist”
Where I expect to get nothing because I want to hide errors.
What am I doing wrong?
That error is from your
diecommand. You cannot suppress adieby turning errors off, as you are explicitly echoing out themysql_errorto the screen before exiting.You should use
trigger_errorin the same way as yourmysql_select_dbline above to remedy this: