Reputation: 14250
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.
Upvotes: 55
Views: 214455
Reputation: 5228
If you get net::ERR_CONTENT_DECODING_FAILED in the console then you are using gzip in your .htaccess file but gzip encoding is Off.
Enable zlib.output_compression=On
in php.ini
and restart Apache
Upvotes: 0
Reputation: 194
In your index.php
file add the line:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
Upvotes: 2
Reputation: 1835
In system/core/Common.php
there is an exception handler, with a block of code that looks like this:
// We don't bother with "strict" notices since they tend to fill up
// the log file with excess information that isn't normally very helpful.
if ($severity == E_STRICT)
{
return;
}
By removing the if
and the return
and the incorrect comment, I was able to get an error message, instead of just a blank page. This project isn't using the most recent version of CodeIgniter, hopefully they've fixed this bug by now.
Upvotes: 1
Reputation: 1
Just for anyone who is still looking for answers:
$db['default']['dbdriver'] = 'mysqli'; (make sure you use mysqli, not mysql). (database.php)
Upvotes: 0
Reputation: 1
The error, In my case, was occurring because my Apache server was configured to run PHP
as Fast CGI
, I changed it to FPM
and it worked.
Upvotes: 0
Reputation: 77984
after installation of xamp/wamp you may notice few errors of similar nature. If your website was already running dont worry, it is a configuration related issue.
1) check database connections in database.php file inside application folder 2) check config.php file check url is correct or not? 3) by default short tags are off in new installations then follow the procedure below
in php.ini file change "short_open_tag=Off" to "short_open_tag=On"
Make sure to restart apache after doing this.
hope this helps.
Upvotes: 0
Reputation: 77984
I was having same problem, i installed latest xamp version and found my site is not working, after research and wasting time i found that.
I need to turn on following tag in php.ini file short_open_tag=On
Make sure to restart apache after doing this.
Hope this helps, most of these problems are related to php.ini file or fresh installation if your site was already running as other people facing similar issue.
Upvotes: 0
Reputation: 2356
I had this same problem and as Shayan Husaini pointed out, I had an undetected syntax error.
I solved it using the php linter in the terminal:
php -l file.php
You can also use something like this to use the linter in every file in some folder:
find -type f -name "*.php" -exec php -l '{}' \;
And to filter just the ones with errors:
find -type f -name "*.php" -exec php -l '{}' \; | grep '^[^N]'
That should show files with parsing errors and the line where the error is.
Upvotes: 11
Reputation: 368
Often when codeigniter displays nothing, there is a syntax error. Mostly if the app was running seamlessly previously, just look around your most recent edits. For me the experience this time was the entire app, not just a page. So I did a quick brain scan for the most recent edits I had done and worked backwards, reviewing each file I had worked on this day. Turned out to be some 'where' clauses in two model files: For instance, I had
$this->db->where('Type' => 'Blog'); rather than $this->db->where('Type', 'Blog');
Upvotes: 0
Reputation: 109
If you're using CI 2.0 or newer, you could change ENVIRONMENT
type in your index.php
to define('ENVIRONMENT', 'testing');
.
Alternatively, you could add php_flag display_errors on
to your .htaccess
file.
Upvotes: 2
Reputation: 161
Another method is to see if you've surpassed the error checking in your code by accident. Search all your code for any instance of error_reporting(). If you call it without parameters, it just returns the current level, and is harmless. If you call it with a parameter, such as 0 (zero), it will turn off error reporting.
You can test for this in CodeIgnitor by looking at their core library under ../system/core/Common.php and finding a section that's at about line 615 that looks like:
if (($severity & error_reporting()) !== $severity)
{
return;
}
Add something like:
if (($severity & error_reporting()) !== $severity)
{
echo "Suppressing errors!";
return;
}
and you should be able to trap for surpassed errors, and debug from there.
Upvotes: 0
Reputation: 41
I had the same problem a couple days ago. My development environment is Win8 and the website was working just fine, but when i uploaded the files to production server (Linux) was displaying a blank page.
Turns out that models and controllers's filenames should start with a uppercase letter.
The file must be called ‘Blog.php’, with a capital ‘B’.
Class names must start with an uppercase letter.
In windows environment this wont matter since windows does not differentiate uppercase and lowercase, but in linux environment, the files wont be displayed.
Hope I've helped.
Upvotes: 4
Reputation: 1366
If you have this in your php.ini:
display_error = On;
and you have this in your CI Application at the same time
error_reporting(0);
you'll get HTTP/1.1 200 OK and a completely bank page.
That's because when display_error is on, the php-fpm always return HTTP code 200. And all the errors to output are forbidden by error_reporting(0).
For CI application,the entry index.php sets up the running environment as bellows:
if(isset($_SERVER['SERVER_ENV'])) {
define('ENVIRONMENT', $_SERVER['SERVER_ENV']);
} else {
define('ENVIRONMENT', 'development');
}
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
In short, when you set ENV directive in your webserver's conf,say Nginx's fastcgi_params:
fastcgi_param SERVER_ENV production;
then CI will automatically set
error_reporting(0);
Upvotes: 0
Reputation: 102745
Since none of the solutions seem to be working for you so far, try this one:
ini_set('display_errors', 1);
http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
This explicitly tells PHP to display the errors. Some environments can have this disabled by default.
This is what my environment settings look like in index.php
:
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*/
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.');
}
}
Upvotes: 116
Reputation: 1279
i was also facing the same problem and tried almost all the things but finally i restarted my server and i found everything started working fine..i don't know how.....i think it was some server side problem that's why my PHP CODE was not giving any error.
Upvotes: 0
Reputation: 5037
Make sure you don't have a blank index.html file in your root folder. It happens :)
Upvotes: 3
Reputation: 139
Codeigniter doesn't seem to throw an error message when I was referencing a view that did not exist.
In my example I had within my controller:
$this->load->view('/admin/index/access_controls/groups/add');
Because the file did not exist, I got a blank "An error has occurred page". I changed the code to:
$this->load->view('/admin/access_controls/groups/add');
This was how I resolved the same issue you seem to be having, hope this helps someone some day.
Upvotes: 0
Reputation: 494
This happens to me whenever I do autoload stuff in autoload.php like the 'database'
To resolve this, If you're using Windows OS
Open your php.ini.
Search and uncomment this line - extension=php_mysql.dll
(Please also check If the PHP directive points to where your extensions is located.
Mine is extension_dir = "C:\php-5.4.8-Win32-VC9-x86\ext"
)
Restart Apache and refresh your page
Upvotes: 5
Reputation: 430
First of all you need to give the permission of your Codeigniter folder, It's might be the permission issue and then start your server.
Upvotes: 2
Reputation: 176
I ran into this because I had a CLI running via cron as the root user, thus creating log files with root:root. When you tried to navigate to a URI everything would work fine but CI exhibiting the blank page likely because it didn't have write permission to the log file.
Upvotes: 0
Reputation: 351
Are you using the @ symbol anywhere?
If you have something like:
@include('page_with_error.php');
You will get a blank page.
Upvotes: 0
Reputation: 1
please check either error folder is in application folder of not in my case i replace error folder in application folder
Upvotes: -1
Reputation: 392
load your url helper when you create a function eg,
visibility function_name () {
$this->load->helper('url');
}
the it will show you errors or a view you loaded.
Upvotes: 0
Reputation: 2094
check if error_reporting is ON at server or not, if that id off you wont get any errors and just blank page. if you are on a shared server then you can enable error reporting via htaccess. In codeIgniter add following in your htaccess
php_flag display_errors On
and set
error_reporting(E_ERROR); ## or what ever setting desired in php
hope it will work for you
Upvotes: 2
Reputation: 4250
This behavior occurs when you have basic php syntax error in your code. In case when you have syntax errors the php parser does not parse the code completely and didnot display anything so all of the above suggestion would work only if you have other than syntax errors.
Upvotes: 7
Reputation: 7618
you can set it in the main 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':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
Upvotes: 6