Q:

Issue with SELECT from database with php

<?php
    try{
        include("dbconnectie.php");
        $query = $db->prepare("SELECT * FROM shop WHERE id_u = :id");
        $query->bindParam("id", $_SESSION['id_u']);
        $query->execute();
        $result = $query->fetchALL(PDO::FETCH_ASSOC);
        echo "<table>";
            foreach($result as &$data) {
                echo "<tr>";
                    echo "<td>" . $data["brand"] . "</td>";
                    echo "<td>" . $data["model"] . "</td>";
                    echo "<td>" . $data["cond"] . "</td>";
                    echo "<td>" . $data["price"] . "</td>";
                echo "</tr>";
            }
        echo "</table>";
    } catch(PDOException $e) {
        die("Error!: " . $e->getMessage());
    }
?>
<html>
    <body>
        <div class="poster">
        <img src="<?php echo $data['img_url']; ?>" width='400' height='300' ></img>
        </div>
    </body>
</html>

So in a different file, $_SESSION['id_u'] was defined as id_u which is in the 'account' table in my database. Now in the 'shop' table I have every sell placement written down with the corresponding user id: "id_u"
Now what I'm trying to do it Select all the sell placements that are put under that user id, but it's not working. Now for some reason it just shows a big border with nothing but a broken image icon. Not even the corresponding text.

A:

Do a session_start(); at the top.

