Welcome Guest, Not a member yet? Register   Sign In
controller/model name conflicts produce a blank page?
#1

[eluser]Johnny Freeman[/eluser]
I've spent a billion years trying to figure out why when I create a controller called 'users' it produces a blank page (even the source is blank). After sifting through many many threads I decided to change the name of my model name called 'users'. It turns out that you cannot have a controller named 'users' if you are loading a model called 'users'. A novice mistake I guess.

What I want to know is, WHY, in the name of all that is good in this world, is there no error produced??? And a blank page instead? I almost stabbed my monitor with my Brave Heart sword!!!
#2

[eluser]Michael Wales[/eluser]
Because of the way CodeIgniter buffers output. Turn off output compression and use ini_set() to turn on error reporting and display_errors.
#3

[eluser]WanWizard[/eluser]
Because error reporting and/or error display is switched off?

If I do that here (tested with a library instead of a model), I get
Code:
Fatal error: Cannot redeclare class TestClass in /data/www/virtual/ci/test/172/system/application/libraries/testclass.php
#4

[eluser]Johnny Freeman[/eluser]
My output compression is off
Code:
$config['compress_output'] = FALSE;
And error reporting is on
Code:
error_reporting(E_ALL);
Still not getting an error message.

I also tried naming my controller the same as one of my libraries (to see if I could generate an error) and I get no error messages here either.
#5

[eluser]Michael Wales[/eluser]
Quote:use ini_set() to turn on error reporting and display_errors
#6

[eluser]Johnny Freeman[/eluser]
Honestly, I don't know where I'd put that. Never really used ini_set before, or display_errors for that matter. Index page?

like...
Code:
<?php

/*
*---------------------------------------------------------------
* PHP ERROR REPORTING LEVEL
*---------------------------------------------------------------
*
* By default CI runs with error reporting set to ALL.  For security
* reasons you are encouraged to change this to 0 when your site goes live.
* For more info visit:  http://www.php.net/error_reporting
*
*/
    error_reporting(E_ALL);
    ini_set();

I really don't know.

I guess I could look up those in the php manual...
#7

[eluser]WanWizard[/eluser]
For a development environment, enable both in php.ini, because certain errors will never be displayed when display errors is off in the config.

At runtime, use
Code:
error_reporting(E_ALL);
ini_set('display_errors', 1);
#8

[eluser]Johnny Freeman[/eluser]
BEAUTIFUL!

I'm now getting the error message. I JUST LOVE ERROR MESSAGES!!! (as opposed to a blank screen) They make my debugging life much less violent.

Thanks for your help!




Theme © iAndrew 2016 - Forum software by © MyBB