如何在 CodeIgniter 中关闭 mysql 错误显示在屏幕上

发布于 2024-07-09 01:50:46 字数 312 浏览 7 评论 0原文

即使 error_reporting 设置为 0,数据库错误仍会打印到屏幕上。 我可以更改某处设置以禁用数据库错误报告吗? 这是针对 CodeIgniter v1.6.x

编辑:回复:修复错误 - 嗯,是的。 我想修复这些错误。 我从错误日志中获得错误通知,而不是从访问者在屏幕上看到的内容中获得错误通知。 这对任何人都没有帮助,而且还会损害我的系统的安全。

编辑2:将 error_reporting 设置为 0 不会影响 CodeIgniter 的内置错误日志记录类写入错误日志。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

猫瑾少女 2024-07-16 01:50:46

找到答案:

config/database.php: 中,

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

所以:

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

...应该禁用。

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.

人生戏 2024-07-16 01:50:46

除了 Ian 的回答之外,要暂时禁用错误消息:

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

// Do your sketchy stuff here

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

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;
烟燃烟灭 2024-07-16 01:50:46
  • 你不想改变
    error_reporting 为 0,因为这会
    还可以抑制错误
    已记录。

  • 相反,你应该改变
    display_errors 为 0

这并不能解释你为什么
虽然显示错误,
假设 error_reporting 实际上是
0. 也许框架会处理这些错误

  • 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

有深☉意 2024-07-16 01:50:46

您可以编辑应用程序目录下的 /errors/db_error.php 文件 - 这是包含数据库错误的模板。

但是,您确实应该修复错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文