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 CRUD Operations with PHP Reading and Writing Reports Filtering Data

Sam Durigon
Sam Durigon
4,724 Points

How is this not an optional parameter?

It's telling me this isn't an optional parameter, but I gave it a default value.

index.php
<?php
function get_people($filter = false) {
    include 'connection.php';

    //add code here

    $query = "SELECT * FROM people";

    if ($filter){
      $query .= " WHERE treehouse = 1";
    }

    $query .= " ORDER BY last_name DESC";
    $stmt = $db->query($query);

    $names = $stmt->fetchAll(PDO::FETCH_ASSOC);
    return $names;
}

1 Answer

Rohald van Merode
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Rohald van Merode
Treehouse Staff

Hey Sam Durigon 👋

Thanks for bringing this to our attention, I'll bring this up with the team to see if we can improve the messaging on this challenge.

It looks like the tests for this challenge are set up to expect a default value of null instead of a false value. While it won't really make a difference to the behavior of your code, it should help you pass the challenge 🙂

Hope this helps!