Php Error Messages

liunx

Guest
I noticed that php scripts don't display very helpful eror messages when they are running on my tch server. In fact, most of the time, an error that would raise a message on my home computer will generate only a blank screen on tch. <br /><br />I think this is great for production sites. But when I'm trying to test and debug scripts, it gets to be hard when all i get is a blank screen instead of the customary error message and line number.<br /><br />Is there any way for me to change the settings for certain scripts or my whole account so that I can get descriptive php error messages?<br /><br />Any help would be appreciated,<br /><br />Thanks,<br />-kyle-<!--content-->
OK...I'm am not a php expert, and this sounds very rudimentary, but shouldn't you be able to write some php code to turn error reporting on or off?<!--content-->
Add the following commands to your .htaccess file in the folder containing the php script (or create an .htaccess file if none exists.)<br /><br />php_flag display_errors on <br />php_value error_reporting 7<!--content-->
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->shouldn't you be able to write some php code to turn error reporting on or off?<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />That's exactly what I'm looking for. I tried a few commands off the php website but they wouldn't take. And, ironically, I couldn't get too far because I don't get much feed back without error reporting.<!--content-->
You go, Rob!!!<!--content-->
Personally, I don't like to turn error reporting on and off via .htaccess. The problem with this method is that I have to modify this file every time I need to debug something. <br /><br />I just thought that an alternative method would be to include something like in the php file<br /><br />if ($_GET['debug']) ini_set('display_errors', '1');<br />else ini_set('display_errors', '0');<br /><br />This way you can turn debugging on and off at any time, by just adding <br />?debug=something to the URL.<!--content-->
I stole my comment from a post Rick made. I couldn't remember the exact resolution so I did a search in the forums.<br /><br />vangrieg, that may be an alternative but for me I am not sure I can remember to type that at the end or to include it in the code. Getting older I have a hard time remembering things. For me it takes 2 seconds in cPanel to modify the file. But hey, if it works then whatever is easiest right?<!--content-->
<!--QuoteBegin-TCH-Rob+Jan 18 2004, 02:38 AM--><div class='quotetop'>QUOTE(TCH-Rob @ Jan 18 2004, 02:38 AM)</div><div class='quotemain'><!--QuoteEBegin-->But hey, if it works then whatever is easiest right?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Absolutely. Cpanel's File Manager is a little slow, that's why I don't like it too much. But otherwise any of the methods does the same thing.<!--content-->
vangrieg, you don't like to leave PGP error reporting on all the time? If so... why?<!--content-->
<!--QuoteBegin-TCH-Robert+Jan 18 2004, 12:30 PM--><div class='quotetop'>QUOTE(TCH-Robert @ Jan 18 2004, 12:30 PM)</div><div class='quotemain'><!--QuoteEBegin-->vangrieg, you don't like to leave PGP error reporting on all the time? If so... why?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> You mean PHP error reporting? Sometimes errors aren't serious enough to prevent visitors from using the site normally, but error reports still show up, messing up the layout. Moreover, the error reports can give away some paths and file names, which may pose certain security risks.<!--content-->
Mm. I see your point. Yes, I meant PHP, lol... Typo daemon got ahold of me.<br /><br />Yes, security is indeed an issue, and it can mess up the layout... I build my websites that all the PHP-intensive stuff is executed before the HTML even begins, so any error messages precede the html coding.<!--content-->
 
Back
Top