PHP Exception handling

Associate
Joined
1 Feb 2006
Posts
1,868
Location
Reading
Can someone tell me why the most simple code (below) throws

Parse error: syntax error, unexpected '{' on line 2

WTF?

I checked some very similar code on another website on the same hosting package and it is now throwing the error aswell! Only thing i can think of is Vidahost recently upgraded to php 5, but the try statement still exists in php 5. This is infuriating me, it's so stupid!

PHP:
<?php
try{
    $conn=$dbh=mysql_connect ("localhost", "", "");// or die ('Cannot connect to the database because: ' . mysql_error());
    mysql_select_db("kimmystr_wordpress");// or die('Could not select database ');
    $pauthor=$_POST["author"];
    $pcontent=$_POST["comment"];
    $result = mysql_query("insert into wp_comments(comment_author, comment_date, comment_content) values('$pauthor', now(), '$pcontent')");// or die('Fail');
    header('Location: http://www.kimmystravels.co.uk/wp-content/themes/main/messages.php?result=success');
  }
  catch (Exception $e) {
    header('Location: http://www.kimmystravels.co.uk/wp-content/themes/main/messages.php?result=fail');
  }
?>
 
Thanks guys, I thought try except had been in php for awhile, silly me.

Strange as I'm sure it worked on my other site without "enabling" it.
 
Back
Top Bottom