...

View Full Version : die function Witch way?



ycpc55
07-26-2012, 06:22 AM
Hi
i been watching tutorial after tutorial, and a lot of them been saying its better to make your die function nice and clean. Also doing so will help secure your script better is this true? should i go with Option (1) or Option (2)


//Option (1) Clean die function:
die();
//Option (2) Way i have it to show any errors die function:
die('Error in query:<br>'. $sql .'<br>'.mysql_error($conn).'<br>Time of Error: '.date("l F j, Y, G:i:s T"));

connormcwood
07-26-2012, 09:17 AM
Hi
i been watching tutorial after tutorial, and a lot of them been saying its better to make your die function nice and clean. Also doing so will help secure your script better is this true? should i go with Option (1) or Option (2)


//Option (1) Clean die function:
die();
//Option (2) Way i have it to show any errors die function:
die('Error in query:<br>'. $sql .'<br>'.mysql_error($conn).'<br>Time of Error: '.date("l F j, Y, G:i:s T"));

Adding in a die option and giving it parameters will just allow to you to know where your code is failing.
P.s You put Witch instead of Which in your title;p

Dormilich
07-27-2012, 06:49 AM
Hi
i been watching tutorial after tutorial, and a lot of them been saying its better to make your die function nice and clean. Also doing so will help secure your script better is this true?

IMO, die() makes your page primarily invalid. either you send (no) text where there should be full HTML page or a truncated HTML page. neither is what the user expects to see.

additionally, debugging info is not supposed to get public. youd better logging that or sending yourself an email of it (or do both).

if a critical error occurs, send the user an error page to explain that something happened that out of the regular.

and therefore Im a fan of exceptions.

ycpc55
07-28-2012, 01:34 AM
Thanks for the help guys.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum