I keep getting an error when I try to add a blog entry into my database. I have a simple syntax highlighter but it is not showing where something is not right.
Error:
PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ')' on line 75 and 71
My script:
if(!isset($error)){
try {
//insert into database
$stmt = $db->prepare('INSERT INTO blog_posts (postTitle,postDesc,postCont,postDate) VALUES (:postTitle, :postDesc, :postCont, :postDate)') ; //line 71
$stmt->execute(array(
':postTitle' => $postTitle,
':postDesc' => $postDesc,
':postCont' => $postCont,
':postDate' => (new DateTime())->format('Y-m-d H:i:s') //Line 75
));
//redirect to index page
header('Location: index.php?action=posted&title='.$postTitle.'');
exit;
} catch(PDOException $e) {
echo $e->getMessage();
}
}