Help - Error messages are turned off!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
zeek
Forum Commoner
Posts: 48
Joined: Mon Feb 27, 2006 7:41 pm

Help - Error messages are turned off!

Post by zeek »

I've been trying to fix a problem for over 2 hours now! The server has error messages turned off (if there's a script error you just get a blank page). I can't fix this without seeing whats wrong. I do not have access to error logs on the server.

Is there a way I can add something to my script to force it to display an error message? It can be sloppy or weird, I just have to FIND OUT WHAT THE ERROR IS! Thanks in advance.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

error_reporting() and ini_set('display_errors') could be of interest, however that won't catch everything.

If your server runs Apache and allows .htaccess files, you can set the error_reporting and display_errors flags in there, however most errors you should be able to catch on your own testing server (your own machine in many cases.)
Superman859
Forum Commoner
Posts: 47
Joined: Sun Oct 29, 2006 10:22 am

Post by Superman859 »

I usually stick with the following two settings when working with PHP code. Just add it first thing in your PHP code.

ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);
User avatar
zeek
Forum Commoner
Posts: 48
Joined: Mon Feb 27, 2006 7:41 pm

Thank you

Post by zeek »

Thank you for your quick replies, I'm trying your suggestions now...

IT WORKED!!! Thank you so much.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's advisable to keep notices on if you're allowing errors to display. They can alert you to small errors in your code that suck up execution time for no good reason.
Post Reply