English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Many of my try/catch blocks have suddenly stopped working. When I throw an exception, the corresponding catch block is ignored, and I'm given the error message:

Fatal error: Uncaught exception 'Exception' with message 'Please ensure that all fields are filled out.' in /home/ goddess/ public_html/ add_blog.php:20 Stack trace: #0 {main} thrown in /home/ goddess/ public_html/add_blog.php on line 20.

I'm baffled! Any ideas why the following block of code would generate such an error message?


try
{

check_valid_user();
if (!filled_out($_POST))
{
throw new Exception('Please ensure that all fields are filled out.');
}

// attempt to add blog
publish_blog($blog_author, $blog_title, $blog_body);
echo 'Blog successfully published!';

}
catch (Exception $e)
{
echo $e->getMessage();
}
display_user_menu();
do_html_footer();
?>

2007-02-28 05:44:27 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

I need more information about your problem, but my first suggestion would be Do not Throw a "new" exception here. Instead, echo the text back to a control or the page so you can debug this in the page and not the logs. Throwing a new exception here "feels wrong"

http://us3.php.net/exceptions

It looks to me like your exception is by default extended beyond the containment of your block.

echo this back and refine your question with the output and I'll help you walk through this.

2007-02-28 06:24:26 · answer #1 · answered by Jason W-S 4 · 0 0

It seems that because the Try / Catch doesn't handle missing field exceptions.

You need to put an if statement checking your fields first to make sure they are filled in and give the user approiate information regarding the fields they didn't fil out. Maybe you missed a field?

2007-02-28 14:14:44 · answer #2 · answered by footose 2 · 0 0

sounds like you have a virus get a nortonantivirus anti spy program or you can totally reformat your comp

2007-02-28 13:48:15 · answer #3 · answered by howdy doody 3 · 0 1

sorry i would give you a good answer if i had an idea what you'r talking about

2007-02-28 13:48:13 · answer #4 · answered by Anonymous · 1 1

fedest.com, questions and answers