简体   繁体   中英

CodeIgniter - Blank page on database autoload

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

in application/config/database.php check that

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

is set to

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

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 (ie 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.

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.

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.

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

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).

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

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');

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM