Mysql Codeigniter-我看不到数据库错误

Mysql Codeigniter-我看不到数据库错误,mysql,database,codeigniter,autoload,Mysql,Database,Codeigniter,Autoload,导航到链接时,我无法在浏览器中看到SQL错误 细节: CodeIgniter 2.2.0 在我的database.php中 $db['default']['dbdriver'] = 'mysql'; $db['default']['db_debug'] = TRUE; 我正在尝试连接到一个旧的“MySQL:5.1.73-cll” 我使用LinuxShell中的MySQL命令测试了IP、用户和密码,效果很好,我能够连接 但是当我在autoload.php中将“数据库”添加到我的$autoload

导航到链接时,我无法在浏览器中看到SQL错误

细节: CodeIgniter 2.2.0

在我的database.php中

$db['default']['dbdriver'] = 'mysql';
$db['default']['db_debug'] = TRUE;
我正在尝试连接到一个旧的“MySQL:5.1.73-cll”

我使用LinuxShell中的MySQL命令测试了IP、用户和密码,效果很好,我能够连接

但是当我在
autoload.php
中将“数据库”添加到我的
$autoload['libraries']
中时,我的页面将完全加载为空白,并且没有显示错误消息。如果我从
$autoload['libraries']
中删除“数据库”,则我的页面将正确加载

如果我能看到错误,我至少会知道问题是什么

谢谢!
Marius

解决方案之一是在代码顶部添加此选项-

ini_set('display_errors', 1);
检查链接:



还要检查您的
环境
。您可以将这些设置添加到基本
index.php

define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/

if (defined('ENVIRONMENT'))
{
   switch (ENVIRONMENT)
   {
      case 'development':
        /* Report all errors */
        error_reporting(E_ALL);

        /* Display errors in output */
        ini_set('display_errors', 1);
      break;

      case 'testing':
      case 'production':
        /* Report all errors except E_NOTICE */
        /* This is the default value set in php.ini */
        error_reporting(E_ALL ^ E_NOTICE);

        /* Don't display errors (they can still be logged) */
        ini_set('display_errors', 0);
      break;

      default:
          exit('The application environment is not set correctly.');
    }
 }

明白了。看起来主要原因是没有安装php mysql模块。我安装了php,mysql,但没有安装此模块。在此之前,我还更新了php.ini文件,但不确定是否需要,或者php mysql的安装是否自行完成。但以下是我所做的,希望这能帮助其他人:

台阶 1)更新PHP.INI

创建一个包含以下内容的info.php文件:

<?php phpinfo(); ?>
并向下滚动以查找现有设置

display_errors = Off
并将其更改为

display_errors = On
注意:有两个地方提到了“显示错误”,一个靠近文件顶部,一个在文件下方,不要像我那样添加或取消注释第一部分中的任何行,因为它将被下面的另一行覆盖。只需通过将“关闭”更改为“打开”来编辑显示错误部分,这就是我所做的

2)安装php mysql

然后安装php mysql并重新启动Web服务器

# sudo apt-get install php5-mysql
3)重新启动web服务器

# sudo /etc/init.d/apache2.restart

您可以通过两种方式看到错误

更改php.ini文件 设置

更改这些之后,您必须重新启动apache服务器

另一个选择是 只需在函数中添加以下两行:

error_reporting(E_ALL);
ini_set('display_errors',"On");

无需重新启动apache服务器。

是您的
php.ini
中设置的
display\u errors
设置吗?它是关闭的。如何打开它?我在php.ini中尝试了nano,并添加了“display\u errors=on”,但在phpinfo中仍然显示为关闭。您需要重新启动web服务器以使更改生效。我现在有了“display\u errors=on”,但它仍然存在l显示一个空白页。我还更改了“display\u startup\u errors=On”,但仍然不走运。当我在Browser中检查“On”标志时,它在phpinfo()中可见,/var/log/apache2/error.log文件中没有错误
error_reporting=E_ALL
display_errors="On"
error_reporting(E_ALL);
ini_set('display_errors',"On");