CodeIgniter - 数据库自动加载的空白页

发布于 2024-11-20 00:05:42 字数 441 浏览 3 评论 0原文

从今天早上开始,我将网站从本地计算机迁移到服务器后遇到了问题。

为了替换上下文,我使用 CodeIgniter 框架开发了一个网站,迁移之前一切都运行良好。

经过长时间的研究,似乎当我放置此内容时:

$autoload['libraries'] = array('database');

我的网站上有一个空白页面,日志中没有任何 php/ci 错误。

如果我这样:

$autoload['libraries'] = array();

网站工作正常(好吧,我无法登录,但我没有空白页面)。

我在 php.ini 文件中添加了 mysql.so,但它也没有帮助我。

有人已经遇到过这个问题吗?请问你怎么解决的?

谢谢 !

I encouter a problem since this morning, after I migrated my website from my local machine to the server.

To replace the context, I developed a website with the framework CodeIgniter, and everything before the migration was working fine.

After a long research, it seems that when i put this :

$autoload['libraries'] = array('database');

I have a blank page on my website, without any php/ci errors in the logs.

And if I let this :

$autoload['libraries'] = array();

The website is working correctly (well, I can't log in but I don't have a blank page).

I added the mysql.so in the php.ini file, but it didn't help me neither.

Does someone already encountered this problem ? How can you solved it please ?

Thanks !

B

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

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

发布评论

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

评论(11

爱情眠于流年 2024-11-27 00:05:45

当你没有安装 php 的 mysql 模块时,就会发生这种情况。在 Windows 中,我相信它带有 php 安装程序。如果您使用的是 Linux,例如 Fedora,则安装方式如下:

sudo yum -y install php-mysql

安装后重新启动 Web 服务器。假设您正在使用 apache httpd:

sudo service httpd restart

现在您应该再次看到这些页面(假设您在 conf/database.php 中具有正确的设置)。

This happens when you don't have mysql module for php installed. In windows, I believe this comes with the php installer. If you are on linux, for example on Fedora, this is how you install it:

sudo yum -y install php-mysql

Restart the webserver after the installation. Assuming you are using apache httpd:

sudo service httpd restart

Now you should see the pages again (assuming you have correct settings in conf/database.php).

聽兲甴掵 2024-11-27 00:05:45

我刚刚遇到这个错误,在调试 MYSQL 驱动程序后我发现了问题。

问题是在数据库配置文件上我使用 MYSQL 作为驱动程序,而在服务器上安装了 MYSQLI,只需在配置文件上更改它即可。

希望这对某人有帮助。

I have just had this error, after debugging the MYSQL driver I figure out the problem.

The problem was that on the database config file I was using MYSQL as a driver when on the server it has installed MYSQLI, just change it on the config file and you're done.

Hope this helps someone.

妥活 2024-11-27 00:05:45

听起来您的数据库配置不正确,并且您的 PHP 安装阻止了错误。

查看您的日志文件或尝试放入

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

您的 index.php 并查看您得到的结果

It sounds like your database is not configured properly and your PHP installation is blocking the errors.

Take a look at your log files or try putting

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

in your index.php and see what you get

独木成林 2024-11-27 00:05:45

对于我来说,使用 Z-WAMP 时遇到同样的问题,必须从 php.ini 中取消注释“extension=php_mysql.dll”。还分配了“mysql.default_port = 3306”和“mysql.default_host = localhost”。希望它能帮助那里的人

For me, having the same issue using Z-WAMP, had to uncomment "extension=php_mysql.dll" from the php.ini. Also assigned "mysql.default_port = 3306" and "mysql.default_host = localhost". Hope it helps someone out there

稍尽春風 2024-11-27 00:05:45

对于那些使用 Linux(尤其是 ubuntu)但仍然出现空白页面的用户,请执行以下操作:

  1. sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-cli mysql-server
  2. sudo service apache2 restart
  3. $autoload['libraries'] = array('database');

For those using linux (esp. ubuntu) and are still getting the blank page, do the following:

  1. sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-cli mysql-server
  2. sudo service apache2 restart
  3. $autoload['libraries'] = array('database');
单挑你×的.吻 2024-11-27 00:05:45

安装 php5-pgsql 为我解决了这个问题(在 Ubuntu 上)

Installing php5-pgsql fixed it for me (on Ubuntu)

神爱温柔 2024-11-27 00:05:45

只需转到 application/config/database.php 并找到

$db['default']['dbdriver'] = 'mysql';

Replace 'mysql' with 'mysqli'

$db['default']['dbdriver'] = 'mysqli';

就可以了!

just go to application/config/database.php and find

$db['default']['dbdriver'] = 'mysql';

Replace 'mysql' with 'mysqli'

$db['default']['dbdriver'] = 'mysqli';

and that's it!

廻憶裏菂餘溫 2024-11-27 00:05:44

在应用程序/配置/database.php
检查是否

$db['default']['dbdriver'] = 'mysql';

设置为

$db['default']['dbdriver'] = 'mysqli';

in application/config/database.php
check that

$db['default']['dbdriver'] = 'mysql';

is set to

$db['default']['dbdriver'] = 'mysqli';
魂牵梦绕锁你心扉 2024-11-27 00:05:44

我遇到了类似的问题,空白页面似乎与加载数据库相关,无论是通过自动加载还是在模型构造函数中调用 $this->load->database(); 。我最终不得不通过注释 extension=php_pdo_mysql.dll 并取消注释 extension=php_mysql.dll (即关闭 PDO)来修改我的“php.ini”文件。我运行的是 Windows 8.1、Apache 2.2 和 PHP 5.3.27。

这个答案与另一个答案类似,但由于我刚刚注册,因此无法添加评论以进行澄清。我花了几个小时和大量的谷歌搜索来解决,所以希望这对某人有帮助。

I had a similar problem with blank pages seemingly associated with loading the database, be it via autoload or calling $this->load->database(); in the model constructor. I ended up having to modify my 'php.ini' file by commenting out extension=php_pdo_mysql.dll and uncommenting extension=php_mysql.dll (i.e. turning PDO back off). I am running Windows 8.1, Apache 2.2, and PHP 5.3.27.

This answer is similar to another, but I couldn't add a comment for clarification since I just signed up. It took me a couple of hours and a lot of Googling to resolve, so hopefully this helps somebody.

孤寂小茶 2024-11-27 00:05:44

您确定您的数据库连接凭据正确吗?如果您切换了服务器,这似乎可能是问题所在。

此外,CodeIgniter 为生产环境设置了 error_reporting(0) —— 因此是空白页。检查您的日志目录(是否可以由网络服务器进程写入......?)以获取任何其他信息。

Are you sure your db connection credentials are correct? If you switchd servers this seems like it might be the issue.

Additionally, CodeIgniter sets error_reporting(0) for production environments --- hence the blank page. Check your logs dir (is it writeable by the webserver process..?) for any other info.

拒绝两难 2024-11-27 00:05:44

请重新启动您的网络服务器并重试。

使用 phpinfo() 创建一个新的 info.php 文件;

<前><代码>

查看 mysql 扩展是否正在加载,如果加载

尝试对您的目录执行 chmod 0777

Please restart your webserver and try again.

create a new info.php file with phpinfo();

<?php

phpinfo();

?>

see if the mysql extension is loading if its loading

try to do a chmod 0777 to your directoy

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