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 trialFrancis Ansu
4,326 Pointshow can I change the function to select a single member from member_id
To set up an account page, you need to select a single member. Change the function to accept the single argument for a member_id.
I don't understand what function I need to change I tried modifying fetchALL to just fetch and also tried calling it in member_id in fetch
fetch(member_id);
<?php
function get_member() {
include("connection.php");
try {
$results = $db->query(
"SELECT member_id, email, fullname, level
FROM members"
);
} catch (Exception $e) {
echo "bad query";
}
$members = $results->fetchAll();
return $members;
}
5 Answers
Robert Stamate
13,227 Points(<?php function get_member($member_id)
)
This should fix it out for you. And I guess you figure it where it was the function argument.
Francis Ansu
4,326 PointsI got it now I forgot the $ sign in my function
<?php function get_member($member_id) { include("connection.php");
try {
$results = $db->query(
"SELECT member_id, email, fullname, level
FROM members"
);
} catch (Exception $e) {
echo "bad query";
}
$members = $results->fetchAll();
return $members;
}
Prince eudes Ononiwu
410 Points<?php function get_member($member_id) { include("connection.php");
try {
$results = $db->query(
"SELECT member_id
FROM members WHERE member_id= '$member_id' "
);
} catch (Exception $e) {
echo "bad query";
}
$members = $results->fetchAll();
return $members;
}
Prince eudes Ononiwu
410 Points<?php function get_member($member_id) { include("connection.php");
try {
$results = $db->query(
"SELECT member_id
FROM members WHERE member_id= '$member_id' "
);
} catch (Exception $e) {
echo "bad query";
}
$members = $results->fetchAll();
return $members;
}
Robert Stamate
13,227 PointsMy bad, I forgot to add it in the first place as well.
I'm clumsy. Sorry.
Francis Ansu
4,326 Pointsno worries you pointed me to the right direction thanks for your help.
Francis Ansu
4,326 PointsFrancis Ansu
4,326 Pointsit returned error maybe we need to change something else i Have tried a lot of things to solve this
To set up an account page, you need to select a single member. Change the function to accept the single argument for a member_id.
<?php function get_member(member_id) { include("connection.php");
}