Codeigniter - I cannot see database errors Codeigniter - I cannot see database errors codeigniter codeigniter

Codeigniter - I cannot see database errors


One of the solution is adding this at the top of your code -

ini_set('display_errors', 1);

Check link: http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors


OR


Also check your ENVIRONMENT. You can add those settings in your base index.php

define('ENVIRONMENT', 'development');/**---------------------------------------------------------------* ERROR REPORTING*---------------------------------------------------------------** Different environments will require different levels of error reporting.* By default development will show errors but testing and live will hide them.*/if (defined('ENVIRONMENT')){   switch (ENVIRONMENT)   {      case 'development':        /* Report all errors */        error_reporting(E_ALL);        /* Display errors in output */        ini_set('display_errors', 1);      break;      case 'testing':      case 'production':        /* Report all errors except E_NOTICE */        /* This is the default value set in php.ini */        error_reporting(E_ALL ^ E_NOTICE);        /* Don't display errors (they can still be logged) */        ini_set('display_errors', 0);      break;      default:          exit('The application environment is not set correctly.');    } }


You can see errors in two ways.

Change you php.ini file set

error_reporting=E_ALLdisplay_errors="On"

After change these you have to restart your apache server.

Another option isJust add these two following lines in your function:

error_reporting(E_ALL);ini_set('display_errors',"On");

No need to restart apache server.


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:

Steps

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