"Alex.Tesi" <[EMAIL PROTECTED]> wrote in message
003901c123fa$1ff2da50$[EMAIL PROTECTED]">news:003901c123fa$1ff2da50$[EMAIL PROTECTED]...
>Hi i have a problem printing a lob field containing an image.
>The database i use is Interbase 6.0
>I have a blob/lob field with a gif image inside an i like to print this
image on the web.
>Can you help me?

You need a script to return the image, and you need to
pass the proper parameter from the calling page...

======= image.php ==========

// check that param exists
if (!isset($img)) {
    // alternatively, you could set img to
    // point to an 'error, not found' image
    // from your database...
    die("Error: 'img' parameter not set");

// hacker prevention...
$img = (int) $img;

// connect to the database
$conn = ibase_pconnect("host:dbase", "usr", "pwd")
        or die("Error: ".ibase_errmsg());

// query for image
$query = "SELECT img_contents "
    ."FROM imgtable WHERE id=$img";
$res = ibase_query($conn, $query);

// make sure that exactly one result was returned
$num_returned = ibase_num_fields($res);
if ($num_returned == 0)
    die("Error: specified image $img not found");
if ($num_returned > 1)
    die("Error: $num_returned images found for $img");

// return image
    // if you kept an image-type field in your
    // database, you could store and retrieve
    // various image types - gif, jpeg, bmp, png,
    // swf, svg, etc...
header("Content-Type: image/gif");
$row = ibase_fetch_object($res);
echo $row->img_contents;


=========== mypage.html =======
    <p>Here is image # 394302...</p>
    <img src='image.php?img=394302' align='center'>

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to