By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,553 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,553 IT Pros & Developers. It's quick & easy.

READ FIRST: Turn On PHP Debugging Messages

Motoma
Expert 2.5K+
P: 3,235
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:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', true);
  4.  
  5. //  Rest of the PHP code
  6.  
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:

Expand|Select|Wrap|Line Numbers
  1. mysql_query($query, $link_id) or die('<hr />MySQL Error: ' .mysql_error(). '<hr />');
  2.  
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
Apr 7 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.