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! While you're at it, check out some resources Treehouse students have shared here.

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

Juan Pablo De Alba Venegas
Juan Pablo De Alba Venegas
5,022 Points

What's wrong? WHERE clause is not working

This is my code, in task 2 I used the variable $id as an argument and used it in the member_id to just show the values of that specific ID but they keep telling me that I need to use a WHERE statement to show one specific value. Please Help

function get_member($id) {

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

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

1 Answer