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 Fetching in a While Loop

Vladislav Mavrin
Vladislav Mavrin
Courses Plus Student 3,125 Points

I receive a php notice in unidentified raw variable

I receive a php notice in unidentified raw variable

would appreciate your help to tackle this


$item = $results->fetch();
if (empty($item)) return $item;
try {
    $results = $db->prepare("
        SELECT fullname, role 
        FROM Media_People
        JOIN People ON Media_People.people_id = People.people_id
        WHERE Media_People.media_id = ?;
    $results->bindParam(1,$id, PDO::PARAM_INT);
} catch (Exception $e) {
  echo "Data is not received";
while ($row = $results->fetch(PDO::FETCH_ASSOC)) {
    $item[$row["role"]][] = $raw["fullname"];
return $item;


<?php echo implode(", ", $item["artist"]); ?>

Notice: Undefined variable: raw in /Applications/XAMPP/xamppfiles/htdocs/projects/inc/functions.php on line 49 array(19) { ["media_id"]=> string(1) "9" [0]=> string(1) "9" ["title"]=> string(30) "Beethoven: Complete Symphonies" [1]=> string(30) "Beethoven: Complete Symphonies" ["category"]=> string(5) "Music" [2]=> string(5) "Music" ["img"]=> string(23) "img/media/beethoven.jpg" [3]=> string(23) "img/media/beethoven.jpg" ["format"]=> string(2) "CD" [4]=> string(2) "CD" ["year"]=> string(4) "2012" [5]=> string(4) "2012" ["genre"]=> string(9) "Classical" [6]=> string(9) "Classical" ["publisher"]=> NULL [7]=> NULL ["isbn"]=> NULL [8]=> NULL ["artist"]=> array(1) { [0]=> NULL } }

notice on raw

1 Answer