I have a php page which retrieves the full url of a remote image and then it has to display it. But im getting the error 'cannot be displayed because it contains errors'. I need this script for an app. Can someone point out error here?
The url is working perfectly because when i echo the url..it is echoing it correctly. So im assuming the error is coming in the imag header or something. please help.
Please note that the database stores the file name of the jpeg...for ex..filename.jpg
<?php
if (isset($_GET['id'])){
$id = $_GET['id'];
}
$username="--";
$password="--";
$hostname = "xxxx";
//connection string with database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
// connect with database
$selected = mysql_select_db("1775125_tourist",$dbhandle)
or die("Could not select examples");
$query = mysql_query("Select * FROM photo_details WHERE place_id = '$id'");
while($row = mysql_fetch_assoc($query)){
$imageData = $row["photo"];
}
$url = "http://optimusone.net46.net/testing_only/uploads/".$imageData;
header('Content-Type: image/jpg');
imagejpeg($url);
?>