PHP Beginners
Section 3 episodes22
$note = $db->query('select * from notes where id = :id', ['id' => $id])->fetch();
Seems like something is wrong here
:id
Fatal error:
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':id'
And further on Jeffrey is replacing the $id with $_GET['id'] from the global object. Did you tried that? Is the $id maybe null ? Because the :id in the query is just a wildcard in order to avoid SQL injection. You can try it this way too:
$note = $db->query('select * from notes where id = ?', $id)->fetch();