I have a image path stored the the database under location upload/imagename.png but I cant get it display on my page any help?
The images are stored in a image folder and in the database like image/name.png but can I take the path from the db and display it?
I have error reporting on but still nothing just a blank page.
<?php include_once('dbconnect.php'); ?>
<?php error_reporting(E_ALL);
ini_set('display_errors', 1); ?>
<?php
if(!empty($_GET['id'])){
//Get image path from database
$result = $con->query("SELECT id, location FROM images WHERE id = {$_GET['id']} AND location = {$_GET['location']}");
if($result->num_rows > 0){
$imgData = $result->fetch_assoc();
echo '<img src='".$row['location']."' />';
}else{
echo 'Image not found...';
}
}
?>
You access the page like http://yoursite.com/recent.php?id=xxx
EDIT: I tried this
<?php include_once('dbconnect.php'); ?>
<?php error_reporting(E_ALL);
ini_set('display_errors', 1); ?>
<?php
if(!empty($_GET['id'])){
//Get image data from database
$result = $con->query("SELECT id, location FROM images WHERE id = {$_GET['id']} AND location = {$_GET['location']}");
if($result->num_rows > 0){
while($imgData = $result->fetch_assoc()){
echo '<img src="'.$imgData['location'].'"/>';
}
}else{
echo 'Image not found...';
}
}
?>
Now I get
Notice: Undefined index: location in /home/vol15_4/epizy.com/epiz_20687250/yourwebprojects.22web.org/htdocs/3/recent.php on line 10
Notice: Trying to get property of non-object in /home/vol15_4/epizy.com/epiz_20687250/yourwebprojects.22web.org/htdocs/3/recent.php on line 12