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 Querying the Database with PHP Working with Results

Please help me Challenge Task 1 of 1 of Integrating PHP with Databases.

$send_offer + $results -> fetchAll();

This is my code. Why is this wrong? I got a message "You need to pass 4 arguments"

index.php
<?php
include "helper.php";

try {
    $results = $db->query(
        "SELECT member_id, email, fullname, level FROM members"
    );
} catch (Exception $e) {
    echo $e->getMessage();
}
//add code below this line
$send_offer = $results -> fetchAll();

2 Answers

thanks a lot.

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Kohane,

I'll admit that I'm not an expert at PHP, but I did create a solution for the challenge with my limited knowledge. I encourage other members of the community to let me know if there's a more concise way to accomplish this.

I started by creating a foreach loop to loop through each item in $results. Inside the loop, I call send_offer and pass an argument for each parameter. This approach passed the challenge.

...
//add code below this line
foreach ($results as $result) {
  send_offer($result['member_id'], $result['email'], $result['fullname'], $result['level']);
}

I hope this helps.