ptmuldoon
02-13-2008, 07:15 PM
I'm trying to retrieve an image (users avatar) from a db, but it only seems to return a blank image. From all my searches, I think I'm on the right track, but its not quite there yet.
I have two files, an test_image file, and an avatar file.
test_image File is just to test and pass an id to the avatar file
<img src="avatar.php?image_id=74"></img>
and the avatar file is
// get the image from the db
$sql = "SELECT avatar, image_type FROM users WHERE id='".$_GET['image_id']."'";
// the result of the query
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
header("Content-type: ".$row['image_type']);
echo $row['avatar']
I have two files, an test_image file, and an avatar file.
test_image File is just to test and pass an id to the avatar file
<img src="avatar.php?image_id=74"></img>
and the avatar file is
// get the image from the db
$sql = "SELECT avatar, image_type FROM users WHERE id='".$_GET['image_id']."'";
// the result of the query
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
header("Content-type: ".$row['image_type']);
echo $row['avatar']