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.

Juan Pablo De Alba Venegas
5,022 PointsWhat'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
<?php
function get_member($id) {
include("connection.php");
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

Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 PointsHey Juan,
the second to last line was modified in your code.
Change $members = $results->fetch(); to $members = $results->fetchAll();.
Regards, Florian