Problem extracting BLOB from Interbase !

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
azis
Forum Newbie
Posts: 2
Joined: Thu Aug 07, 2003 6:31 am

Problem extracting BLOB from Interbase !

Post by azis »

Hi

I have a problem and hope you can help me

I need to insert an image into the Interbase (BLOB SUB_TYPE 0 SEGMENT SIZE 800)
and afterwards to be able to extract it someware on my web page, but I still can not extract it right

This works but it displays only the image

<?PHP
include("sysvars.php");
$id = 108;

$dbh = ibase_pconnect($hostweb, $username, $password);
$sth = ibase_query($dbh, 'SELECT IMAGE FROM "BROSHURI" WHERE ID=' . $id);

//echo "<br>TEST<br>";

while($row = ibase_fetch_object($sth))
{
ibase_blob_echo($row->IMAGE);
}
?>


If I uncomment the //echo "<br>TEST<br>";
than the image is gone and disppalyed like : BM6@6(U@@3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›/љ&#152;) &#152;1« ‘„(њЏ0 ”$&#152;‹/Ёљ&#152;‰џ”!§›џ&#152;ђЊ:ЎЈDџ¤5Ђ‰YљўV“—4pp%ccO“’FЋЋSЎ C–—<””......................................

I insert it like :
............

$fd2 = fopen ($image, "rb");
$bloby2 = ibase_blob_import($fd2);
.......

I presumed that the headers were the problem but I tried some things and still nothing

Can some one please help me ?
Thanks
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

You need to send a header to set the content-type to the type of object you want to display. Note, you cannot send both text/html and the image from the same page. Create a separate page to server up the BLOB and where you want your image displayed do something like:

<img src='ShowImage.php?ID=108'>

ShowImage.php will set it's content type to image/jpg or whatever and stream to the browser.

Phil
azis
Forum Newbie
Posts: 2
Joined: Thu Aug 07, 2003 6:31 am

Post by azis »

Yes It worked :D

Thanks Phil
Post Reply