[Php] Codeigniter displays a blank page instead of error messages


Answers

Make sure php5-mysql is installed.

Question

I'm using Codeigniter, and instead of error messages I'm just getting a blank page. Is there any way to show PHP error messages instead? It's very hard to debug when I get no feedback.

My environment is Ubuntu with Apache.




I am not sure what was the real reason but I had a PHP installation with left-over php.ini file. Later I installed the full WAMP stack with its own PHP. When I deleted the leftover php.ini file from the previous installation then it started working as it should. It seems the PHP binaries in the new installing was using using the left-over php.ini which was in totally different directory; maybe because that directory was in environment PATH.




CodeIgniter View page is empty

This is not the problem with your view page. go to config folder open autoload.php

$autoload['helper'] = array('url');

Other Way

Uncomment the #$this->load->helper('url'); to $this->load->helper('url');

<?php

class Users_model extends CI_Model {

    function __construct()
    {
        parent::__construct();

        $this->load->database();
        $this->load->helper('url');

    }   

    public function get_all_users()
    {
        $query = $this->db->get('users');
        return $query->result();
    }

}

?>



Even though there are accepted answers I wanted to add a way that worked for me to figure out this problem.

Usually the "Blank Page" indicates a PHP parsing error somewhere in the code. Strange thing for me was that on my local MAMP based test server the code ran fine. I FTP it to my hosted server and all of a sudden, blank page of death.

Even though I had errors on, log errors on, display errors on, nothing appears in any log file.

I was able to find the error by a funny little trick. I added an echo line in CodeIgniter.php in the system/core. Obviously hacking the core was not a great idea but all I wanted to do was to see how far it was getting in the load process.

When my echo appeared after trying to load a page on the remote hosted server it also displayed the parsing problem in a derived controller! Not sure why the error did not come out without the "echo" added. But adding it seemed to trigger some output to be generated, IE my echo line and the PHP parse error was appended.

Not sure if this will help anyone but it turned out to be a nice easy way to find the error which only showed on the remote server.

Obviously, don't forget to put your core file back to its original state without the echo.




Instead of this <?php echo base_url();?>index.php/user/add_form Use: <?php echo site_url('user/add_form');?>




How to configure Codeigniter to report all errors?

It depends on your version of CI. For < 2.x edit the top level index.php and adjust the error_reporting function to use E_ALL"

error_reporting(E_ALL);

For >= 2.x edit the top level index.php and make sure ENVIRONMENT is set as:

define('ENVIRONMENT', 'development');

which sets the error_reporting to E_ALL.