Re: DB-stored images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ohlson Stefan wrote:
Hi!

I have a db where we stores images in the database but I haven't figured out how I display
that image after I've selected it from the table.

I've tried with <IMG SRC='$data'> and <IMG SRC=$data> but $data just return the Select-query:
<html><head><title></title></head>
<body bgcolor=cccccc text=000000 link=0000ff vlink=0000ff>
<B>Picture</B><BR><UL>
<IMG SRC='SELECT PICTURE FROM KATALOGUE WHERE ISBN = '91-29-65480-7''>
</UL></body></html>
I'm not familiar with fetching data from Oracle, but the output you get doesn't really look like image data.

Anyone have an idea what I can do?
Thanks!
First of all you should verify that you infact have stored image data in your table and it really is that data your fetching.

Then to display the image you need to separate the image output from the rest of your script. Something like this:
getimg.php (Just cut'n'pasted'n'edited from your script)
<?php
$handle = ORA_LOGON("something/something","") OR DIE("Unable to connect to database");
$SqlStatement = "SELECT PICTURE FROM KATALOGUE WHERE ISBN = '$isbn'";

$csr = ORA_OPEN($handle) OR DIE("Unable to open data database cursor");
ORA_PARSE($csr, $SqlStatement)OR DIE("Unable to parse query");
ORA_EXEC($csr) OR DIE("Unable to run query");

ORA_FETCH($csr)
$data = ORA_GETCOLUMN($csr,0);
header('Content-Type: image/jpeg');
echo $data;
?>

Then in your_script.php do something like this:
<?php
echo "<IMG SRC=\"getimg.php?isbn=$isbn\">";
?>

You will probably have to modify it to fit your needs...

Regards
Joakim


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux