Ive just ported my entire PHP project from my university webserver to my canadian hosting and the following code is causing an error.
Its a try throw catch paradigm basically. and when ran it gives the error that
"Parse error: parse error, unexpected '{' on line 14".
Line 14 is the 'try {'.
Whats going on? its an exact code copy from university and it doesnt run on my hosting.
Please help.
Thankyou
CODE SNIPPET IN QUESTION BELOW
try {
if (!isset($_REQUEST["ISBN"]))
throw new Exception("",MALFORMED_ISBN);
$bookDB = new BookGateway();
$Booktemplate = $bookDB->getBook(intval($_REQUEST["ISBN"]));
include_once("templates/Booktemplate.html");
}
catch (Exception $e)
{
switch ($e->getCode())
{
case NO_CONNECTION:
$Exception["MSG"] = "<p>Could not create a database connection<p>". "<h2>Error Message</h2>". $e->getMessage();
include_once("templates/Exception.html");
break;
case MALFORMED_ISBN:
$Exception["MSG"] = "<p>Error in syntax<p>". $e->getMessage();
include_once("templates/Exception.html");
break;
case QUERY_FAILED:
$Exception["MSG"] = "The last query failed with error message".$e->getMessage();
include_once("templates/Exception.html");
break;
case NO_RESULTS:
$Exception["MSG"] = "Sorry there is no record with ISBN value {$_REQUEST['ISBN']} in the database";
include_once("templates/Exception.html");
break;
}
}