Marius Marius - 1 year ago 90
SQL Question

Codeigniter - I cannot see database errors

I cannot see the SQL errors in my browser when I navigate to links.


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
my page loads blank completely and there is no error message displayed. If I remove the 'database' from
then my page loads correctly.

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


Answer Source

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

<?php phpinfo(); ?>

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-mysql

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