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 Querying Multiple Tables with JOIN

6,116 Points

unable to retreat data if i use join

if i use the codes with line join and outer left join for some reason i get unable to retrieve data

``` 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)); ```

1 Answer

Dennis Amiel Domingo
Dennis Amiel Domingo
15,961 Points

Typo, add an "s" here on the word "Genre"

JOIN Genre ON Media.genre_id = Genres.genre_id

should be

JOIN Genres ON Media.genre_id = Genres.genre_id