view image odbc + sybase + php

hello scenario -------------- images stored as binary in sybase odbc-connection swali -------- how do i view the image in a browser? i have tried (almost) everything in vain. this is my code ------------------------ <?php function hex2bin($data){ $len = strlen($data); return pack("H" . $len, $data); } $connH=odbc_pconnect("myDB","me","mypassword") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='1'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_CONVERT); $m_FValue=odbc_result($result, 1); header("Content-Type: image/jpeg"); echo $out=hex2bin($m_FValue); } ?>

Try use the php script as the image in the <img> tag: <img src="script.php"> On Wed, Mar 17, 2010 at 10:55 AM, ukuta ken <ukutaken@gmail.com> wrote:
hello
scenario --------------
images stored as binary in sybase odbc-connection
swali --------
how do i view the image in a browser? i have tried (almost) everything in vain.
this is my code ------------------------
<?php
function hex2bin($data){ $len = strlen($data); return pack("H" . $len, $data); }
$connH=odbc_pconnect("myDB","me","mypassword") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='1'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_CONVERT); $m_FValue=odbc_result($result, 1); header("Content-Type: image/jpeg"); echo $out=hex2bin($m_FValue); } ?> _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Regards, Brian Ngure

Done that. Still doesn't work. On 3/17/10, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote:
Try use the php script as the image in the <img> tag:
<img src="script.php">
On Wed, Mar 17, 2010 at 10:55 AM, ukuta ken <ukutaken@gmail.com> wrote:
hello
scenario --------------
images stored as binary in sybase odbc-connection
swali --------
how do i view the image in a browser? i have tried (almost) everything in vain.
this is my code ------------------------
<?php
function hex2bin($data){ $len = strlen($data); return pack("H" . $len, $data); }
$connH=odbc_pconnect("myDB","me","mypassword") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='1'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_CONVERT); $m_FValue=odbc_result($result, 1); header("Content-Type: image/jpeg"); echo $out=hex2bin($m_FValue); } ?> _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

Ive seen some interesting read here: http://www.php.net/manual/en/function.odbc-longreadlen.php On Wed, Mar 17, 2010 at 11:06 AM, ukuta ken <ukutaken@gmail.com> wrote:
Done that. Still doesn't work.
On 3/17/10, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote:
Try use the php script as the image in the <img> tag:
<img src="script.php">
On Wed, Mar 17, 2010 at 10:55 AM, ukuta ken <ukutaken@gmail.com> wrote:
hello
scenario --------------
images stored as binary in sybase odbc-connection
swali --------
how do i view the image in a browser? i have tried (almost) everything in vain.
this is my code ------------------------
<?php
function hex2bin($data){ $len = strlen($data); return pack("H" . $len, $data); }
$connH=odbc_pconnect("myDB","me","mypassword") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='1'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_CONVERT); $m_FValue=odbc_result($result, 1); header("Content-Type: image/jpeg"); echo $out=hex2bin($m_FValue); } ?> _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f...
------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f...
------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- www.golavish.com - The travel and leisure www.raccuddasys.com - code Development issues

On Wed, Mar 17, 2010 at 10:55 AM, ukuta ken <ukutaken@gmail.com> wrote:
$connH=odbc_pconnect("myDB","me","mypassword") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='1'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_CONVERT); $m_FValue=odbc_result($result, 1); header("Content-Type: image/jpeg"); echo $out=hex2bin($m_FValue); } ?>
Doesnt sybase have a 'blob' / 'var binary' field type ... ? why are you doing this conversion from hex2bin ? Why dont you store the image as binary ?

I have tried many other options, I just assumed that if the i could convert to hex, blob the data and then re-convert it would work. Here is some more code that DOES NOT work ------------------------------------------ <?php $connH=odbc_pconnect("myDB","me","mypass") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='2'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_RETURN); $out=odbc_result($result, 1); } ?> ---------------------------------------- On 3/17/10, ashok+skunkworks@parliaments.info <ashok+skunkworks@parliaments.info> wrote:
On Wed, Mar 17, 2010 at 10:55 AM, ukuta ken <ukutaken@gmail.com> wrote:
$connH=odbc_pconnect("myDB","me","mypassword") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='1'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_CONVERT); $m_FValue=odbc_result($result, 1); header("Content-Type: image/jpeg"); echo $out=hex2bin($m_FValue); } ?>
Doesnt sybase have a 'blob' / 'var binary' field type ... ? why are you doing this conversion from hex2bin ? Why dont you store the image as binary ? _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

On Wed, Mar 17, 2010 at 11:21 AM, ukuta ken <ukutaken@gmail.com> wrote:
------------------------------------------ <?php
$connH=odbc_pconnect("myDB","me","mypass") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='2'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_RETURN); $out=odbc_result($result, 1); } ?>
I remember that in older versions of sql server (which was almost a cousin of sybase) you had to set the textsize when retrieving binary data ... otherwise the default textsize returned by the db for blobs and var-binary data types was 32 kilobytes or something like that ... can you set the textsize to a large number before your retreival query and see if it works ? something like 'set textsize 1024000' ?

have also done that, still nothing <?php odbc_exec($connH, "set textsize 131072"); On 3/17/10, ashok+skunkworks@parliaments.info <ashok+skunkworks@parliaments.info> wrote:
On Wed, Mar 17, 2010 at 11:21 AM, ukuta ken <ukutaken@gmail.com> wrote:
------------------------------------------ <?php
$connH=odbc_pconnect("myDB","me","mypass") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='2'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_RETURN); $out=odbc_result($result, 1); } ?>
I remember that in older versions of sql server (which was almost a cousin of sybase) you had to set the textsize when retrieving binary data ... otherwise the default textsize returned by the db for blobs and var-binary data types was 32 kilobytes or something like that ...
can you set the textsize to a large number before your retreival query and see if it works ? something like 'set textsize 1024000' ? _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

Actually i was doing everything right. The binary image can be opened in adobe photoshop and on conversion by leadtools can be displayed by the browser. So now i have to use curl and do some conversions before display. Is there any shortcut??? On 3/17/10, ukuta ken <ukutaken@gmail.com> wrote:
have also done that, still nothing <?php odbc_exec($connH, "set textsize 131072");
On 3/17/10, ashok+skunkworks@parliaments.info <ashok+skunkworks@parliaments.info> wrote:
On Wed, Mar 17, 2010 at 11:21 AM, ukuta ken <ukutaken@gmail.com> wrote:
------------------------------------------ <?php
$connH=odbc_pconnect("myDB","me","mypass") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='2'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_RETURN); $out=odbc_result($result, 1); } ?>
I remember that in older versions of sql server (which was almost a cousin of sybase) you had to set the textsize when retrieving binary data ... otherwise the default textsize returned by the db for blobs and var-binary data types was 32 kilobytes or something like that ...
can you set the textsize to a large number before your retreival query and see if it works ? something like 'set textsize 1024000' ? _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

Is the image stored in the database actually a JPEG as specified in your header? On Wed, Mar 17, 2010 at 5:41 PM, ukuta ken <ukutaken@gmail.com> wrote:
Actually i was doing everything right. The binary image can be opened in adobe photoshop and on conversion by leadtools can be displayed by the browser.
So now i have to use curl and do some conversions before display. Is there any shortcut???
On 3/17/10, ukuta ken <ukutaken@gmail.com> wrote:
have also done that, still nothing <?php odbc_exec($connH, "set textsize 131072");
On 3/17/10, ashok+skunkworks@parliaments.info<ashok%2Bskunkworks@parliaments.info> <ashok+skunkworks@parliaments.info <ashok%2Bskunkworks@parliaments.info>> wrote:
On Wed, Mar 17, 2010 at 11:21 AM, ukuta ken <ukutaken@gmail.com> wrote:
------------------------------------------ <?php
$connH=odbc_pconnect("myDB","me","mypass") or die(odbc_errormsg()); $result=odbc_exec($connH, "select top 1 image from images where id='2'"); if ($result) { odbc_longreadlen($result, 131072); odbc_binmode($result,ODBC_BINMODE_RETURN); $out=odbc_result($result, 1); } ?>
I remember that in older versions of sql server (which was almost a cousin of sybase) you had to set the textsize when retrieving binary data ... otherwise the default textsize returned by the db for blobs and var-binary data types was 32 kilobytes or something like that ...
can you set the textsize to a large number before your retreival query and see if it works ? something like 'set textsize 1024000' ? _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f...
------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1f... ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
participants (5)
-
ashok+skunkworks@parliaments.info
-
Brian Ngure
-
Frankline Chitwa
-
Rad!
-
ukuta ken