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 Understanding SQL Injections

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

[SOLVED] Joins not supported in Workspaces

Hi all,

I've followed the video as best I can but I keep getting the following error in my browser.

Unable to retrieve results: SQLSTATE[HY000]: General error: 1 RIGHT and FULL OUTER JOINs are not currently supported

When attempting to load a media item on details.php.

Any ideas?

<?php

function single_item_array($id) {

    include("connection.php");
    try {
          $results = $db->query("
            SELECT media_id, title, category, img, format, year, genre, publisher, isbn 
            FROM Media
            JOIN Genres ON Media.genre - 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: ";
          echo $e->getMessage();
          exit;
        }



    $catalog = $results->fetch(PDO::FETCH_ASSOC);
    return $catalog;

}
?>

I've linked to a Workspaces snapshot.

https://w.trhou.se/9umla5fcax

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

This issue was purely to do with with the query i was attempting to use.

<?php
$results = $db->prepare("
            SELECT title, category, img, format, year, publisher, isbn, genre
            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 = ?"
                           );

?>

I also needed to stored it was a prepared query.