Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Integrating PHP with Databases Using Relational Tables Using a Prepared Statement

Joshua Esmero
Joshua Esmero
10,571 Points

Issue with question 3 - Answer should be correct, but it is not recognised

Hi, I think something is wrong with the code challenge - question 3. I'm pretty sure I've done it right, but it is saying that question 2 has stopped working because I changed

WHERE member_id = $member_id


WHERE member_id = ?

function get_member($member_id) {

    try {
      $results = $db->prepare(
          "SELECT member_id, email, fullname, level
          FROM members
          WHERE member_id = $member_id"
      $results->bindParam(1, $id, PDO_PARAM_INT);
    } catch (Exception $e) {
      echo "bad query";

    $members = $results->fetchAll();
    return $members;

1 Answer

Shane Oliver
Shane Oliver
19,977 Points

Your call to the PDO static is wrong

$results->bindParam(1, $id, PDO::PARAM_INT);
Joshua Esmero
Joshua Esmero
10,571 Points

Thanks for that, I thought I copied it properly from the video lol.