READ FIRST: Turn On PHP Debugging Messages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    READ FIRST: Turn On PHP Debugging Messages

    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:

    Code:
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    
    //  Rest of the PHP code
    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:
    mysql_query($query, $link_id) or die('<hr />MySQL Error: ' .mysql_error(). '<hr />');
    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.

    Thank you for reading,
    Motoma
    Last edited by Markus; Dec 11 '08, 01:14 PM. Reason: Fixed le code tags.
Working...