Why is this code causing a syntax error? Why can't I catch the exception?
protected function RunQuery($sql) {
$pdo = $this->conn;
$stmt = $pdo->prepare($sql);
if($stmt) {
$stmt->execute($sql);
} else {
print_r("Unable to prepare the query");
}
catch(PDOException $e) {
print_r($e);
exit(0);
}
}
catchstatement. Why is that statement there?catchalways works withtry, with the syntaxtry{ /*code*/ }catch(Exception $e){ /*code*/ }. see php.net/manual/fr/language.exceptions.php