how to see database errors Codeigniter ?

CodeIgniter 2.2.0

In my database.php I have

$db['default']['dbdriver'] = 'mysql';
$db['default']['db_debug'] = TRUE;
And I am trying to connect to an old `MySQL: 5.1.73-cll"

I tested the IP, user and password using MySQL command from linux shell and it works fine, I am able to connect.

But when I add the 'database' to my $autoload['libraries'] in autoload.php my page loads blank completely and there is no error message displayed. If I remove the 'database' from $autoload['libraries'] then my page loads correctly.

If I could see the error I would at least know what the issue is.

asked Jun 2, 2015 in codeinither by rajesh
0 votes

2 Answers

0 votes
Got it. It looks like the main reason was the fact that php-mysql module was not installed. I had PHP Installed, MySQL installed but not this module. Before that I also updated PHP.ini file, but not sure if that was needed or if the install of php-mysql does it by itself anyways. But here is what I did and hopefully this will help others:


1) Update PHP.INI

Create a info.php file with the content of

and launch it to find out the correct location of PHP.INI file. Check the location of PHP.ini file in "Loaded Configuration File" then edit PHP.ini file

# sudo nano /etc/php4/apache2/php.ini
and scroll down to find the existing setting

display_errors = Off
and change it to

display_errors = On
NOTE: There are 2 places where 'display_errors' is mentioned, one close to the top of the file, one a bit below, don't add or uncomment any line in the first section, like I did, as it will be overwritten by the other line below. Just edit the display_errors part by changing 'Off' into 'On', that's what I did

2) Install php-myql

Then install the php-mysql and restart the webserver

# sudo apt-get install php5-mysql
3) Restart web server

# sudo /etc/init.d/apache2.restart
Thanks for all the help. Thank you 'doitmyway'!
answered Jun 2, 2015 by rajesh
0 votes
You can see errors in two ways.

Change you php.ini file set

After change these you have to restart your apache server.

Another option is Just add these two following lines in your function:

No need to restart apache server.
answered Jun 2, 2015 by rajesh