CodeIgniter - Blank page on database autoload
Asked Answered
U

11

6

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

Unnerve answered 13/7, 2011 at 14:23 Comment(0)
O
2

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.

Osteoclasis answered 13/7, 2011 at 14:25 Comment(7)
I tried to connect with the commandline and everything was OK so I presume it won't be a problem to have the same credentials in database.php fileUnnerve
I also have : error_reporting(E_ALL); and the only line in the log concerning the db is : DEBUG - 2011-07-13 16:37:57 --> Database Driver Class InitializedUnnerve
search your app (from the root dir) for any other instances of "error_reporting" -- CI may be overriding the setting after youOsteoclasis
check your webserver or php logs, (php log location should be visible in php.ini), webserver logs location depend on the server..Osteoclasis
That's what I said in the post, I have no php or apache errors :(Unnerve
No i don't have anything of it.Unnerve
OK it seems to be a mysql error. I remove the @ before the mysql_connect in the system/database/drivers/mysql/mysql_driver.php and I got this error : Fatal error: Call to undefined function mysql_connect() in path_to_my_site/system/database/drivers/mysql/mysql_driver.php on line 70. I'll check for the mysql version then...Unnerve
J
7

in application/config/database.php check that

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

is set to

$db['default']['dbdriver'] = 'mysqli';
Jeb answered 18/4, 2016 at 21:26 Comment(0)
D
4

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.

Doak answered 22/10, 2013 at 20:59 Comment(0)
O
2

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.

Osteoclasis answered 13/7, 2011 at 14:25 Comment(7)
I tried to connect with the commandline and everything was OK so I presume it won't be a problem to have the same credentials in database.php fileUnnerve
I also have : error_reporting(E_ALL); and the only line in the log concerning the db is : DEBUG - 2011-07-13 16:37:57 --> Database Driver Class InitializedUnnerve
search your app (from the root dir) for any other instances of "error_reporting" -- CI may be overriding the setting after youOsteoclasis
check your webserver or php logs, (php log location should be visible in php.ini), webserver logs location depend on the server..Osteoclasis
That's what I said in the post, I have no php or apache errors :(Unnerve
No i don't have anything of it.Unnerve
OK it seems to be a mysql error. I remove the @ before the mysql_connect in the system/database/drivers/mysql/mysql_driver.php and I got this error : Fatal error: Call to undefined function mysql_connect() in path_to_my_site/system/database/drivers/mysql/mysql_driver.php on line 70. I'll check for the mysql version then...Unnerve
M
1

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

Merengue answered 16/7, 2011 at 7:42 Comment(0)
E
1

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

Estrone answered 2/4, 2012 at 8:16 Comment(0)
P
1

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.

Pittance answered 6/6, 2012 at 19:16 Comment(0)
T
0

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

Tsana answered 13/7, 2011 at 14:26 Comment(2)
that is turned off in codeigniter configuration, that won't workDeluca
The db parameters seems to be OK as I can connect it with the commandline, and I can reached it on my machine. The DB server is not local aswell.Unnerve
P
0

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

Preoccupy answered 10/2, 2013 at 3:25 Comment(0)
C
0

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');
Condonation answered 12/12, 2013 at 21:11 Comment(0)
L
0

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

Lindon answered 16/2, 2015 at 7:55 Comment(0)
B
0

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!

Bulbous answered 8/10, 2019 at 6:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.