Page 1 of 1

done debuggin, now what?

Posted: Tue Oct 22, 2002 1:31 pm
by Zoram
When I have finished debugging a script how do i make it so that it doesn't display the errors etc when there is an error....?

Posted: Tue Oct 22, 2002 2:45 pm
by waskelton4
if your server is win

Edit php.ini so..

display_errors = off

there are also switches, if you like, to post your errors/warnings/notices to a file.

Posted: Tue Oct 22, 2002 6:19 pm
by Zoram
I dont' have access as far as i know to the ini file.

Posted: Tue Oct 22, 2002 6:24 pm
by volka
http://www.php.net/manual/en/ref.errorf ... -reporting

Code: Select all

error_reporting		E_ALL & ~E_NOTICE		PHP_INI_ALL 
display_errors		"1"			PHP_INI_ALL
you can change those values with ini_set

Posted: Tue Oct 22, 2002 7:07 pm
by protokol
Put this at the top of each script:

// Turns off error reporting for the duration of the script the function is called in
error_reporting(0);

Posted: Wed Oct 23, 2002 3:39 am
by twigletmac
You can use the '@' symbol in front of a line of code to suppress any errors that might arise that you can't prevent, eg:

Code: Select all

@mail($to, $subject, $message);
there's also the or die() statement to quit a script when something like a database is down:

Code: Select all

@mysql_connect($host, $user, $pass) or die(error_message());
you can put a custom function call into the die() function so that you can decide how errors are displayed.

IMHO, you shouldn't need to turn error_reporting off if you've done thourough testing of your site before making it live and got rid of errors that are under your control as well adding procedures to catch those that aren't especially when it comes to dodgy user input.

Mac

Thanks Twigletmac!

Posted: Wed Oct 23, 2002 7:48 pm
by Zoram
That's what i was looking for! Thanks!