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 Using Relational Tables Using a Prepared Statement

Jacob Wick
Jacob Wick
8,912 Points

doubly stumped lol

I noticed from the other answers that this question is asking for me to use the PDO::PARAM_INT object, but now I'm not sure what is wrong

index.php
<?php
function get_member($id) {
    include("connection.php");

    try {
      $results = $db->query(
          "SELECT member_id, email, fullname, level
          FROM members
          WHERE members.member_id = ?"
      );
      $results->bindParam(1,$id,PDO::PARAM_INT);
      $results->execute();
    } catch (Exception $e) {
      echo "bad query";
    }

    $members = $results->fetch();
    return $members;
}

1 Answer

Pascal Breitrück
PLUS
Pascal Breitrück
Courses Plus Student 3,206 Points

Hey 👋 , you‘re problem is in the WHERE.

You should not write the tablename after where like this members.member_id = ?

You SELECT ........ FROM table WHERE ...... . You only write member_id = ? after the WHERE, because you select the table with the FROM keywords.

Greets Pascal