Subject | How can i retrieve image from BLOB field using php ? |
---|---|
Author | Tommy Cheng |
Post date | 2008-02-29T15:11:32Z |
Dear all,
Below are the codes that can retrieve image from BLOB field of
Firebird, but i think it is too complicated .. could anyone help me
to simplied it ..thx
<?php
if (isset($_GET["getimage"]))
{
$conn = connect();
getimage(@$_GET["getimage"], @$_GET["field"]);
exit;
}
?>
<?php
function connect()
{
$conn = ibase_connect
("localhost:C:/AppServ/Firebird/Image.FDB", "SYSDBA", "masterkey");
return $conn;
}
function sql_select()
{
global $conn;
$sql = "SELECT BLOBIMAGE FROM STKIMAGE";
$res = ibase_query($conn, $sql) or die(ibase_errcode());
return $res;
}
function getimage($recid, $field)
{
$res = sql_select();
$row = ibase_fetch_assoc($res, IBASE_FETCH_BLOBS);
echo $row[$field];
}
function outimage($recid, $field) //outimage($recid, $field, $alt,
$width, $height)
{
$res = "<img src=\"i.php?getimage=$recid&field=$field\" border=0
alt=\"$alt\"";
$res = $res.">";
return $res;
}
?>
<?php echo outimage($i, "BLOBIMAGE")?>
Tommy
Below are the codes that can retrieve image from BLOB field of
Firebird, but i think it is too complicated .. could anyone help me
to simplied it ..thx
<?php
if (isset($_GET["getimage"]))
{
$conn = connect();
getimage(@$_GET["getimage"], @$_GET["field"]);
exit;
}
?>
<?php
function connect()
{
$conn = ibase_connect
("localhost:C:/AppServ/Firebird/Image.FDB", "SYSDBA", "masterkey");
return $conn;
}
function sql_select()
{
global $conn;
$sql = "SELECT BLOBIMAGE FROM STKIMAGE";
$res = ibase_query($conn, $sql) or die(ibase_errcode());
return $res;
}
function getimage($recid, $field)
{
$res = sql_select();
$row = ibase_fetch_assoc($res, IBASE_FETCH_BLOBS);
echo $row[$field];
}
function outimage($recid, $field) //outimage($recid, $field, $alt,
$width, $height)
{
$res = "<img src=\"i.php?getimage=$recid&field=$field\" border=0
alt=\"$alt\"";
$res = $res.">";
return $res;
}
?>
<?php echo outimage($i, "BLOBIMAGE")?>
Tommy