Hi there.
I have a problem with selecting and displaying binary data( images)
DB Engine - Postgress
ODBC - unixODBC
PHP - 4.1.2
I connect to postgres via ODBC.
Have problems with displaying data of type BYTEA ( images )
here code of script selecting and displaying images:
= script name print_img ================================================
$dbconn = odbc_connect( "DSN", "DB", "pwd");
$result = odbc_exec ($dbconn,"SELECT image_type, image FROM ogrenci WHERE
id_no=1");
odbc_binmode( $result, 1 );
odbc_longreadlen( $result, 16384 ); // all imges are not greater than 10Kb.
$num = odbc_num_rows($result);
for ($i=0; $i<$num; $i++) {
odbc_fetch_row($result, $i);
odbc_result($result,"image_type");
echo Header("Content/type: ".odbc_result($result,"image_type")."\"");
$img = stripcslashes( odbc_result($result,"image"));
echo $img;
}
==================================================================
All imges are not greater than 10Kb.
most of images can not be displayed and few looks corrupted...
However, when I use Postgres function:
==================================================================
$dbconn1 = pg_connect (".....);
$result = pg_exec ($dbconn1,"SELECT image_type, image FROM ogrenci WHERE
id_no=1");
$num = pg_numrows($result);
for ($i=0; $i<$num; $i++) {
$r = pg_fetch_row($result, $i);
Header("Content/type: ".($r[0])."\"");
echo stripcslashes($r[1]);
}
==================================================================
all imges displayed just fine!
can any body help with ODBC?
Ling.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php