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 trialJustin Roberts
14,583 PointsI think there's a problem with this code challenge. It's saying fatal error, function name must be a string.
I'm not sure what the problem is here. As far as I can see, this is correct. The directions are kind of ambiguous though, it would be helpful to see the helper.php file.
<?php
include "helper.php";
try {
$results = $db->query(
"SELECT member_id, email, fullname, level FROM members"
);
} catch (Exception $e) {
echo $e->getMessage();
}
$results = $results->fetchAll(PDO::FETCH_ASSOC);
//add code below this line
foreach($results as $result) {
send_offer($result("member_id"), $result("email"), $result("fullname"), $result("level"));
}
2 Answers
Colin V
5,784 PointsAlright, I was able to finish the challenge with 1 simple minor change to your code. Not sure if you're going to say "Dang, I should have seen that" or, "huh, I didn't know that" but:
The problem your code has is the way it's grabbing array values. You have the right idea, you get the value of an array using the key, but you're using parentheses() instead of brackets[] which is causing the error.
Justin Roberts
14,583 PointsOh man, stupid mistake, thanks!
Colin V
5,784 PointsHah, no problem! Easy mistake to make!