# Image wont load from DataBase

**URL:** https://forum.kirupa.com/t/image-wont-load-from-database/331818
**Category:** Uncategorized
**Created:** [October 30, 2013, 4:23am UTC](https://forum.kirupa.com/t/image-wont-load-from-database/331818 "2013-10-30T04:23:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Jake\_Aquilina](https://avatars.discourse-cdn.com/v4/letter/j/a4c791/32.png) [@Jake\_Aquilina](https://forum.kirupa.com/u/Jake_Aquilina)
#### Post date: [October 30, 2013, 4:23am UTC](https://forum.kirupa.com/t/image-wont-load-from-database/331818/1 "2013-10-30T04:23:10Z")

</div>

i am unable to get images from my database, images are located in a folder, i am using the location of a city, to get images from melbourne, where i am able to view the images. i have gotten it to view the names, and broken image links but am unsure why this is not working

\<?php include(’\_includes/connection.php’);  
if (isset($db) === true) {  
// could use header redirection to error page  
}  
if(!empty($_GET[‘id’])){  
$id = intval($GET[‘id’]);  
$sql = “SELECT PictureID, PhotoName, LocationId  
FROM picture  
where LocationId=’$id’”;  
}else{  
//header(“Location: [http://localhost/testWorldPic/index.php](http://localhost/testWorldPic/index.php)”);  
exit();  
}  
//use an approach which mixes object oriented with mysql … code  
$query = $db-\>query($sql);  
// testing loop which is similar to using php "mysql_…" functions in appearance - loops through the associative array  
while($row = $query-\>fetch(PDO::FETCH\_ASSOC)){  
echo ‘\<a href="pictures.php?id=’ .$row[‘LocationId’]. ‘"\>’ .$row[‘PhotoName’]. ‘\</a\>\<br/\>’;  
echo ‘\<img src="photos/’ .$row[‘PhotoName’].’ height=“300” width=“200” /\>’. ‘\</a\>\<br/\>’;

}  
?\>
