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 trialSAHIL SANWAL
6,116 Pointsgetting unable to retreat
function single_item_array($id) {
include("connection.php");
try{
$results = $db->query(
"SELECT title, category,img, format, year,genre,publisher,isbn
FROM Media
JOIN Genre ON Media.genre_id = Genres.genre_id
LEFT OUTER JOIN Books ON Media.media_id=Books.media_id
WHERE Media.media_id = $id"
);
echo "retrieved results";
} catch (Exception $e){
echo "unable to retrieve results";
exit;
}
$catalog = $results->fetch();
return $catalog;
}
var_dump( single_item_array(1));```
jonathan wise
51 Pointstry{ $results = $db->query( "SELECT Media.media_id, title, category, img, format, year, genre, publisher, isbn FROM Media JOIN Genres ON Media.genre_id = Genres.genre_id LEFT OUTER JOIN Books ON Media.media_id = Books.media_id WHERE Media.media_id = $id" ); }catch (Exception $e) { echo "Unable to retrieve results"; exit; }
Try this :)
1 Answer
Dennis Amiel Domingo
17,813 PointsYou forgot to add an "s" on the word "Genre" in your JOIN statement.
"Genre"...
JOIN Genre ON Media.genre_id = Genres.genre_id
should be "Genres"
JOIN Genres ON Media.genre_id = Genres.genre_id
Siddhant Mehta
Courses Plus Student 478 PointsSiddhant Mehta
Courses Plus Student 478 Pointswill you please paste link of your workspace snapshot but in your query you are joining Genre and comparing Genres.genre_id try to correct this is error still exist paste your workspace screenshot.