Thursday, 5 September 2013

PDO prepared SELECT statement isn't working

PDO prepared SELECT statement isn't working

i'm having a hard time trying to retrieve data from a table using PDO
prepared statements,
Below is my code which isn't working, $post is always empty.
//connection to db has been made
$stmt = $db->prepare("SELECT * FROM posts WHERE id = ?");
$stmt->bindValue(1,$_GET['id']);
$post = $stmt->fetchAll(PDO::FETCH_ASSOC);
I'm quite confident the problem occurs in the third line, so please let me
know if there is another way to get the data rather than
fetchAll(PDO::FETCH_ASSOC).
Thanks alot.

No comments:

Post a Comment