Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Code Igniter give me a white page? [closed]

Hey, not sure why CodeIgniter is giving me a blank page when I load a simple model. I'm breaking the code down, backwards, and I can't figure out what's breaking. Here's the controller:

class Leads extends Controller {

function Leads() {
    parent::Controller();
    $this->load->scaffolding('leads');
  }

function index() {
    $data = array( 'title' => 'Lead Management' );

    $this->load->view('html_head', $data);
    $this->load->view('leads/home');
    $this->load->view('html_foot');

  }

function view() {
    $this->load->model('Leads');
    $this->load->view('html_head');
    $this->load->view('leads/view');
    $this->load->view('html_foot');
  }

}

Here's the model:

class Leads extends Model {

function Leads()    {
    parent::Model();
}

}

The only way I don't get a white page on /view is if I comment out the loading of the model. I have absolutely no idea what I'm doing wrong, I'm copying the examples and structure literally right off the CI site.

like image 231
dmanexe Avatar asked Jan 27 '10 18:01

dmanexe


People also ask

How do I enable error reporting in ci4?

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.


2 Answers

Ah, the classic Codeigniter white screen of death. I ran into this the first time I used CI. Unbelievably frustrating that such a popular framework could cause something like this with no error output.

In my particular case, it was because I attempted to use the Database class with MySQLi, but my target environment didn't have the MySQLi module installed. For some reason, CI suppressed all the usual error output, so it turned a 2-minute investigation into a 2-hour investigation.

So that being said, I'd check the following things:

  • error_reporting set to E_ALL in your php.ini, and display_errors is on.
  • Turn on log_errors as well.
  • Check that the classes you're using don't rely on a special PHP module that you might not have

If you can't find anything with error output, you're going to have to dig deeper. If you have xdebug installed, I'd highly suggest using that... surround your code in a trace and see where it's choking.

I ended up having to find the cause of my WSOD by drilling down through the framework classes itself and dumping output (no xdebug was available). It's not fun, but it eventually worked.

like image 98
zombat Avatar answered Oct 06 '22 00:10

zombat


Both your classes are named "Leads". When CI includes these, they are loaded into the same namespace. You probably have a "Cannot redeclare class 'Leads'" error. Try renaming the model and you should be fine.

Edit: guess confirmed

like image 32
Dan Soap Avatar answered Oct 05 '22 23:10

Dan Soap