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();
}
}
(new DateTime())->format('Y-m-d H:i:s')
<--- where did you see such a syntax? – zerkms Apr 10 '14 at 3:10(new Model)->method()
, github.com/laravel/framework/issues/1436 , look for the first comment from May 29. – user2094178 Jun 28 '14 at 20:43