Demonic Posted February 3, 2007 Share Posted February 3, 2007 Well, when I make a error notice in my software say if I use die or exit it shuts the html off I was wonder how can I stop this flaw,should I just make header/footer file and include them then running a error. Quote Link to comment https://forums.phpfreaks.com/topic/36931-solved-help-with-errors/ Share on other sites More sharing options...
wildteen88 Posted February 3, 2007 Share Posted February 3, 2007 If you want your scripts to still run when an error occurs the don't use die or exit. just echo the error message and the rest of the code in your script will continue to run. Quote Link to comment https://forums.phpfreaks.com/topic/36931-solved-help-with-errors/#findComment-176202 Share on other sites More sharing options...
Demonic Posted February 3, 2007 Author Share Posted February 3, 2007 Well for example: The header will show, then I tell the user if hes banned it will show the message but not the rest of the html(rest of the script,footer) so the footer is cut off completely. ( I was thinking maybe a redirect or something I not sure what Ill do). Quote Link to comment https://forums.phpfreaks.com/topic/36931-solved-help-with-errors/#findComment-176205 Share on other sites More sharing options...
pocobueno1388 Posted February 3, 2007 Share Posted February 3, 2007 Yeah...there isn't a way to get to your footer then. I just did what you said about putting the footer in another file and including it after the errors. Quote Link to comment https://forums.phpfreaks.com/topic/36931-solved-help-with-errors/#findComment-176207 Share on other sites More sharing options...
phil88 Posted February 3, 2007 Share Posted February 3, 2007 or, rather than using the die() function, you could write your own function to handle the error. Eg; function error_handler($error){ echo "Formatting, layout etc."; echo $error; die(); } And then just use error_handler("Something bad happened") in your code instead of die() or exit. The whole point of the die() function is to stop executing all code right there and the. If a die() function is executed, the script does just that, it dies. Edit: Forgot to put the die() in the function...without that, it'll output your error and then try to continue executing any code that it hasn't executed yet. Quote Link to comment https://forums.phpfreaks.com/topic/36931-solved-help-with-errors/#findComment-176208 Share on other sites More sharing options...
Demonic Posted February 3, 2007 Author Share Posted February 3, 2007 Thanks ill try both ways thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/36931-solved-help-with-errors/#findComment-176217 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.