Page 1 of 1

problems extracting image from mysql db

Posted: Sun Feb 29, 2004 9:32 am
by bogdanb
in index.php I have the code:

<img src="image-get.php?id=1" border="0">

and image-get.php has the code

<?php

if($image_id) {

// Database connection //
@mysql_connect("localhost","xxx","yyy") or die ("Can not connect to given host");
@mysql_select_db("zzz") or die ("Can not connect to database");


$query = @mysql_query("select image, type from imagini where id=$image_id");
$image = @mysql_result($query,0,"image");
$type = @mysql_result($query,0,"type");

Header( "Content-type: $type");
echo $image;

};
?>


I'm able to connect to db but the index.php files returns a red cross square instead of the picture. Any ideas?

images in MzSQL

Posted: Sun Feb 29, 2004 3:33 pm
by istankov
As I see You put your images in BLOB? right?

Just put URL address in table, and use it as:

<img src ='$Photo_url' width='$Foto_W'....>