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 trialJuan 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