problems extracting image from mysql db

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bogdanb
Forum Newbie
Posts: 3
Joined: Tue Feb 24, 2004 12:00 am

problems extracting image from mysql db

Post 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?
istankov
Forum Newbie
Posts: 2
Joined: Sun Feb 29, 2004 3:33 pm

images in MzSQL

Post 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'....>
Post Reply