How to turn off mysql errors from being displayed to screen in CodeIgniter

北战南征 提交于 2019-12-03 08:26:05

问题


Even though error_reporting is set to 0, database errors are still being printed to screen. Is there a setting somewhere I can change to disable database error reporting? This is for CodeIgniter v1.6.x

EDIT: Re: Fixing errors - Um, yes. I want to fix the errors. I get error notices from my error log, not from what my visitors see printed to their screen. That helps no one, and hurts my system's security.

EDIT 2: Setting error_reporting to 0 does not affect CodeIgniter's built-in error logging class from writing to the error log.


回答1:


Found the answer:

In config/database.php:

// ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.

so:

$db['default']['db_debug'] = FALSE;

... should disable.




回答2:


In addition to Ian's answer, to temporarily disable the error messages:

$db_debug = $this->db->db_debug;
$this->db->db_debug = false;

// Do your sketchy stuff here

$this->db->db_debug = $db_debug;



回答3:


  • You don't want to change error_reporting to 0, because that will also suppress errors from being logged.

  • instead you should change display_errors to 0

This doesn't explain why you are getting errors displayed though, assuming error_reporting is actually 0. Maybe the framework handles these errors




回答4:


You can edit the /errors/db_error.php file under the application directory - that is the template included for DB errors.

However, you should really just fix the errors.



来源:https://stackoverflow.com/questions/288559/how-to-turn-off-mysql-errors-from-being-displayed-to-screen-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!