I am attempting to get the path of an image in an SQLite database. This is my code:
<img src="<?php
$database = new PDO("sqlite:database.sqlite");
$database->query("SELECT path FROM images WHERE receiverId = '$_COOKIE['session']'");
?>" />
The table is images and the id of the user is stored in the cookie.
An image has 3 entries: id
, senderId
and receiverId
. If the receiverId
is the same as the cookie id (the user id), the image should be displayed. However, this code is not working. How can I fix it/recode it?