Monday, July 28, 2014

How to enable displaying php errors on site, php.ini .htaccess

How to enable displaying php errors on site

Temporary displaying of PHP errors is important and helpful for solving different problems on the website. For example:
  • Blank page will be displayed instead of content on your site or
  • 500 Error message will be displayed.
Displaying blank page is mostly caused by some PHP error in the code. If error reporting is on (displaying PHP errors is enabled) then it is very easy to find the error and solve the problem.
You can set PHP error reporting on in php.ini file (in case you have access to this file). Set the following lines:
error_reporting  =  E_ALL
display_errors = On
If you have installed your server e.g. with help of XAMPP, see the documentation where to find thephp.ini file. Don't forget to stop Apache server before doing modifications and start it again after saving these modifications.
If you have no access to php.ini file but you can modify .htaccess file on your server (in root of your public_hml folder - your Joomla! site), try to add the following code there (on some servers this option is disabled, so you need to ask your webhosting operator):
# Displaying PHP errors
php_flag display_errors on
php_value error_reporting 6143
If you cannot access the .htaccess file or your modifications in this file have no effects, try to ask your webhosting provider for enabling error reporting or try to see your error log file (should be located outside your public_html folder), which can give you important information too.

After you will get the information about the problem and you will solve this problem, you should disablephp error reporting again, so no error will be displayed for the public (because of security reasons).
Sometimes the problem can be caused by not correctly executed SQL query. Enabling Debug mode in Global Configuration of Joomla! can complete imformation displayed by PHP error reporting. In Global Configuration you can specify the displaying of PHP errors too (Global Configuration - Error Reporting). But be aware, it has no effect if the displaying of PHP errors is disabled on the server.
Summary - Getting as much information about errors can done by following actions:
  • Setting PHP error reporting to on in php.ini file
  • Setting PHP error reporting to on in .htaccess file
  • Setting PHP error reporting to maximum in Global Configuration in Joomla!
  • Setting Debug Mode in Global Configuration in Joomla!
  • Getting information from error log file.

No comments: