CodeIgniter - 数据库自动加载的空白页
从今天早上开始,我将网站从本地计算机迁移到服务器后遇到了问题。
为了替换上下文,我使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
当你没有安装 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).
我刚刚遇到这个错误,在调试 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.
听起来您的数据库配置不正确,并且您的 PHP 安装阻止了错误。
查看您的日志文件或尝试放入
您的
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
in your
index.php
and see what you get对于我来说,使用 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
对于那些使用 Linux(尤其是 ubuntu)但仍然出现空白页面的用户,请执行以下操作:
sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-cli mysql-server
sudo service apache2 restart
$autoload['libraries'] = array('database');
For those using linux (esp. ubuntu) and are still getting the blank page, do the following:
sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-cli mysql-server
sudo service apache2 restart
$autoload['libraries'] = array('database');
安装 php5-pgsql 为我解决了这个问题(在 Ubuntu 上)
Installing php5-pgsql fixed it for me (on Ubuntu)
只需转到 application/config/database.php 并找到
Replace
'mysql'
with'mysqli'
就可以了!
just go to application/config/database.php and find
Replace
'mysql'
with'mysqli'
and that's it!
在应用程序/配置/database.php
检查是否
设置为
in application/config/database.php
check that
is set to
我遇到了类似的问题,空白页面似乎与加载数据库相关,无论是通过自动加载还是在模型构造函数中调用
$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 outextension=php_pdo_mysql.dll
and uncommentingextension=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.
您确定您的数据库连接凭据正确吗?如果您切换了服务器,这似乎可能是问题所在。
此外,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.
请重新启动您的网络服务器并重试。
使用 phpinfo() 创建一个新的 info.php 文件;
查看 mysql 扩展是否正在加载,如果加载
尝试对您的目录执行 chmod 0777
Please restart your webserver and try again.
create a new info.php file with phpinfo();
see if the mysql extension is loading if its loading
try to do a chmod 0777 to your directoy