Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Joshua Esmero
Joshua Esmero
10,323 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,950 Points

Your call to the PDO static is wrong

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

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