You are here:Home»KB»Programming»PHP»Turn On PHP Debugging Messages
Thursday, 15 October 2009 00:00

Turn On PHP Debugging Messages

Written by

Debugging messages are a powerful tool; however, many production systems (and test systems for that matter) have them disabled by default. If your PHP script is crashing horribly and you are not getting any runtime error messages, it is likely that this is the case for you.

You can initiate PHP debugging messages for the server by changing the display_errors and error_level settings in php.ini. Unfortunately, this is not the best situation in a production system. Luckily, you can enable error reporting on a page by page basis by simply adding the following lines to the top of your PHP script: {geshibot language="php"}

Additionally, to assist with debugging MySQL errors in PHP scripts, you can tack on an additional die clause to your MySQL queries. The following lines will cause your script to halt when a MySQL query fails, and report the error message:

{code class="brush: php"}mysql_query($query, $link_id) or die('
MySQL Error: ' .mysql_error(). '
');{/code}

If you script is not producing any error messages, please try these two methods before posting your question in the board. Remember, the community experts can only be as helpful as you are, and they can only work with what you give them.

 

Read 623 times Last modified on Wednesday, 12 November 2014 23:16