Error reporting handling in Codeigniter

CodeIgniter default environment is development and so error reporting by default in turn on state, if you want to turn off reporting then change the environment value(in the top of the main index.php) to production or testing.

The above method will work with only For >= 2.x ci version. For < 2.x edit the top level index.php and adjust the error_reporting function to use E_ALL.Instead of E_ALL, you can change it to any of the predefined error constant.

Database Errors

The PHP errors are off, but any MySQL errors are still going to show. To turn these off , go to the application/config/database.php file and then Set the db_debug option to false:

So, if the error messages are hidden, how else can we tell if something is not working right? Well, CI can writes out any errors it encounters into its log file. You can configure your CI log file by going to the config.php file in your applications/config directory and set value to $config['log_threshold'] .
Note: Make your /application/logs folder writable

Threshold options are: You can enable error logging by setting a threshold over zero. The threshold determines what gets logged. Threshold options are:

0 = Disables logging, Error logging TURNED OFF
1 = Error Messages (including PHP errors)
2 = Debug Messages
3 = Informational Messages
4 = All Messages

You can also pass in a array with threshold levels to show individual error types

array(2) = Debug Messages, without Error Messages

For a live site you’ll usually only enable Errors (1) to be logged otherwise your log files will fill up very fast.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.


I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.

  • Rakesh Panchal

    hi arjun,
    i m facing problem with image upload in CI,

    when i select image and submit form, then after page show me blank page, so its not showing me any error so i cant find it solution.

    here is my code :


    $config[‘upload_path’] = ‘./images/’;
    $config[‘allowed_types’] = ‘gif|png|jpg|jpeg’ ;

    //Load upload library and initialize configuration

    $uploadData = $this->upload->data();
    $picture = $uploadData[‘file_name’];
    $picture = ”;
    $picture = $res[0][‘image’];
    $data = array(
    ‘firstname’ => $this->input->post(‘firstname’),
    ’email’ => $this->input->post(’email’),
    ‘password’ => $this->input->post(‘password’),
    ‘city’ => $this->input->post(‘city’),
    ‘country’ => $this->input->post(‘country’),
    ‘dob’ => $this->input->post(‘dob’),
    ‘gender’ => $this->input->post(‘gender’),
    ‘designation’ => $this->input->post(‘designation’),
    ‘date_added’ => date(‘Y-m-d’),
    ‘image’ => $picture
    // print_r($data);
    $this->db->where(‘id’, $id);
    $this->db->update(‘users’, $data);


    let me know when i get stuck.

  • Mark Twigg

    Guys honestly? What are you’s playing at? You shouldn’t be turning error reporting off, you should be catching and handling your errors correctly (and probably logging them). Don’t just turn them off and ignore them, you can’t be serious? Protection Status