Skip to Content.
Sympa Menu

freetds - Re: [freetds] Image Data converted to Text/String out of MSSQL??

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT ais.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Image Data converted to Text/String out of MSSQL??
  • Date: Sat, 8 Mar 2003 18:26:58 -0500 (EST)

dblib on Windows appears not to convert images to character strings per
se. Can anybody with msdblib.dll verify this? I don't have time to cook
up a proper unittest, perhaps someone else does.

Brian

On Sun, 9 Mar 2003, Andrew Atkinson wrote:

> On Windows I am using the extention dll packaged with PHP (php_mssql.dll).
>
> This is how I built PHP and FreeTDS on Redhat 7.3 (my PHP code below):
>
> #
> # ----- freetds
> #
> cd /usr/local/src/freetds-0.61
> ./configure --prefix=/usr/local/pkgs/freetds-0.61 --with-tdsver=8.0
> --enable-msdblib
> make
> make install
>
> # I then graft freetds into /usr/local so there are links available for
> php below
>
> graft -i -v -t /usr/local /usr/local/pkgs/freetds-0.61
>
> #
> # ----- PHP
> #
> cd /usr/local/src/php-4.3.1
> ./configure --prefix=/usr/local/pkgs/php-4.3.1 --enable-debugger
> --enable-magic-quotes --with-apxs=/usr/local/apache/bin/apxs
> --with-sybase=/usr/local --enable-track-vars
>
> make
> make install
>
> An ldd on the apache extention shows:
>
> # ldd /usr/local/apache/libexec/libphp4.so
> libsybdb.so.3 => /usr/local/pkgs/freetds-0.61/lib/libsybdb.so.3
> (0x4018d000)
> libpng.so.2 => /usr/lib/libpng.so.2 (0x401cc000)
> libz.so.1 => /usr/lib/libz.so.1 (0x401ed000)
> libcrypt.so.1 => /lib/libcrypt.so.1 (0x401fb000)
> libresolv.so.2 => /lib/libresolv.so.2 (0x40228000)
> libm.so.6 => /lib/i686/libm.so.6 (0x40239000)
> libdl.so.2 => /lib/libdl.so.2 (0x4025b000)
> libnsl.so.1 => /lib/libnsl.so.1 (0x4025f000)
> libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
> /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
>
>
> Here's essentially what I am doing in the PHP code:
>
> <?php
>
> $hostname = "<host>";
> $username = "<user>";
> $password = "<password>";
> $dbName = "[database]";
>
> MSSQL_CONNECT($hostname,$username,$password) or DIE("SERVER FAILED
> TO RESPOND.");
> mssql_select_db($dbName) or DIE("DB unavailable");
> $query = "SELECT mypic FROM pictable where pickey = '1234'";
> $result = MSSQL_QUERY($query);
> $number = MSSQL_NUM_ROWS($result);
>
> $i=0;
>
> if ($number == 0) :
> print "No data?";
> elseif ($number > 0) :
>
> Header ("Cache-Control: no-cache, must-revalidate");
> Header ("Pragma: no-cache");
> Header ("Content-type: image/jpeg");
>
> while ($i < $number) :
> $pic = mssql_result($result,$i,"mypic");
> print $pic;
> print "
> ";
> $i++;
> endwhile;
> endif;
> ?>
>
>
> Thanks,
> Andrew
>
>
> ----- Original Message -----
> From: Brian Bruns <camber AT ais.org>
> Date: Sunday, March 9, 2003 0:18 am
> Subject: Re: [freetds] Image Data converted to Text/String out of MSSQL??
>
> > This is a pure PHP problem, specifically:
> >
> > dbconvert(NULL,coltype(offset),dbdata(sybase_ptr->link,offset),
> > res_length,SYBCHAR,res_buf,-1);
> >
> > Converts the results data to SYBCHAR without exception. I'm not
> > sure why
> > this works on Windows, are you using the ODBC driver there or
> > msdblib.dll?
> > Brian
> >
> > On 8 Mar 2003, Frediano Ziglio wrote:
> >
> > > Il sab, 2003-03-08 alle 07:39, Andrew Atkinson ha scritto:
> > > > Hi,
> > > >
> > > > Hope you can help with this one:
> > > >
> > > > I would like to stop FreeTDS converting image data from a
> > MSSQL Server
> > > > DB to a string. I am trying to display an image from a MSSQL
> > DB in a
> > > > browser but the data is just appearing as a long string of
> > hex. The
> > > > source datatype in the database is of type "IMAGE". I have
> > set text
> > > > size in freetds.conf to about 64k. The image is about 11k
> > (see from
> > > > freetds.log below). I don't believe that this is the cause of the
> > > > problem. I am using TDS V8.0 (built and set in freetds.conf).
> > > >
> > > > My environment is as follows:
> > > > Win2K
> > > > MS SQL Server 2000
> > > > Linux - Redhat 7.3
> > > > Apache 1.3.27
> > > > OpenSSL 0.9.7a
> > > > PHP 4.3.1
> > > > FreeTDS 0.61
> > > >
> > > > If I look at the debug in freetds.log I can see the data
> > comming across
> > > > from MSSQL as binary. dbconvert() then converts this SYBIMAGE
> > (34) to
> > > > SYBCHAR (47). This is exactly what I want to stop. See
> > freetds.log below.
> > > >
> > > > Can I stop behaviour this by altering tds_willconvert() or
> > tdsconvert.h,> > or is there a more sensible way of doing it??
> > > >
> > > >
> > > > 0a20 c2 0f fd 06 ea bf 5d bc 2b ff 00 20 6d 2b fe bd
> > |Â.ý.ê¿]¼ +ÿ. m+þ½|
> > > > 0a30 47 f2 86 ba 31 f8 7a 78 4c 4f b2 a0 e5 4d 46 31
> > |Gò.º1øzx LO² åMF1|
> > > > 0a40 77 8c 9c 25 bc 96 ae 1c ad ad 36 7a 7c b4 3c fc
> > |w..%¼.®. ­­6z|´<ü|
> > > > 0a50 6e 1e 96 12 a5 3f ab a7 4f 9a 32 6e d2 96 f1 71
> > |n...¥?«§ O.2nÒ.ñq|
> > > > 0a60 b5 9d ef a5 fd 36 ec 7e 6b 78 df fe 09 8d f0 f6
> > |µ.ï¥ý6ì~ kxßþ..ðö|
> > > > 0a70 14 37 5e 10 f8 a3 e3 6d 10 16 8d 56 df c4 5a 4e
> > |.7^.ø£ãm ...VßÄZN|
> > > > 0a80 87 e2 a4 54 95 49 71 1c da 7b 78 7e 44 06 35 51
> > |.â¤T.Iq. Ú{x~D.5Q|
> > > > 0a90 89 7e d0 41 dc 77 12 ec 4f cf 7f 15 bf e0 9d 3e
> > |.~ÐAÜw.ì OÏ..¿à .>|
> > > > 0aa0 22 f0 07 83 35 2f 1a f8 6b e2 66 87 e2 3b 1f 0f
> > |"ð..5/.ø kâf.â;..|
> > > > 0ab0 d8 ae a3 ad 69 da d7 87 af fc 2d 78 2d fc 8f b4
> > |خ£­iÚ×. ¯ü-x-ü.´|
> > > > 0ac0 39 d3 ae b4 ed 43 5b 8a fe 62 0e 04 57 10 d9 aa
> > |9Ӯ´íC[. þb..W.٪|
> > > > 0ad0 92 d8 94 67 8f db 8f 13 7f c7 8a fd 6d ff 00 f4
> > |.Ø.g.Û.. .Ç.ýmÿ.ô|
> > > > 0ae0 4b 57 8e fc 79 ff 00 92 0b f1 3b fe c5 5f fd c6
> > |KW.üyÿ.. .ñ;þÅ_ýÆ|
> > > > 0af0 ad 71 54 cc b1 f8 69 d1 54 f1 53 71 9c a0 a5 19
> > |­qṮøiÑ TñSq. ¥.|
> > > > 0b00 da 69 ae 58 ab 5e 49 cb bb f8 af 76 f5 b6 87 25
> > |Úi®X«^IË »ø¯võ¶.%|
> > > > 0b10 3c 45 68 ca 2b da 36 94 92 b3 d7 47 51 c7 5b f9
> > |<EhÊ+Ú6. .³×GQÇ[ù|
> > > > 0b20 23 f9 79 59 3c c0 ac a0 80 c8 ed 83 c6 70 9b dd
> > |#ùyY<, .Èí.Æp.Ý|
> > > > 0b30 b6 0f 95 3e 40 14 22 8c 63 e5 24 a8 c1 f4 df 84
> > |¶..>@.". cå$¨Áôß.|
> > > > 0b40 72 32 7c 54 f8 73 e5 85 5c 78 ff 00 c2 f0 a8 00
> > |r2|Tøså. \xÿ.Âð¨.|
> > > > 0b50 05 12 1d 6f 4e 39 38 19 f2 58 a3 65 39 c0 20 7c
> > |...oN98. òX£e9À ||
> > > > 0b60 c0 0d be 5b 07 fa b8 bf eb 84 bf fa 4f 5e 9d f0
> > |À.¾[.ú¸¿ ë.¿úO^.ð|
> > > > 0b70 93 fe 4a a7 c3 9f fb 29 3e 15 ff 00 d3 dd 9d 7d
> > |.þJ§Ã.û) >.ÿ.ÓÝ.}|
> > > > 0b80 c4 9b 78 49 49 e8 e5 19 dd fa 46 56 fb b9 55 bb
> > |Ä.xIIèå. ÝúFVû¹U»|
> > > > 0b90 74 3d 39 fc 13 5d 1c 5a 7f 34 7f ff d9 fd 10 00
> > |t=9ü.].Z .4.ÿÙý..|
> > > > 0ba0 c1 00 01 00 00 00 |Á.....|
> > > >
> > > >
> > > > 2003-03-08 15:31:57.740995 leaving dbnextrow() returning -1
> > > > 2003-03-08 15:31:57.741064 dbdatlen() type = 34
> > > > 2003-03-08 15:31:57.741082 leaving dbdatlen() returning 11082
> > > > 2003-03-08 15:31:57.741105 inside tds_willconvert()
> > > > 2003-03-08 15:31:57.741122 inside tds_willconvert() 34 47 1
> > > > 2003-03-08 15:31:57.741139 dbdatlen() type = 34
> > > > 2003-03-08 15:31:57.741154 leaving dbdatlen() returning 11082
> > > > 2003-03-08 15:31:57.741282 inside dbconvert() srctype = 34
> > desttype = 47
> > > > 2003-03-08 15:31:57.741307 inside dbconvert() calling tds_convert
> > > > 2003-03-08 15:31:57.749205 inside dbconvert() outputting 22164
> > bytes> > character data destlen = 22164
> > > > 2003-03-08 15:31:57.749281 inside dbnextrow()
> > > > 2003-03-08 15:31:57.749304 processing row tokens. marker is
> > fd(DONE)> > 2003-03-08 15:31:57.749363 inside tds_process_end()
> > more_results = 0,
> > > > was_cancelled = 0
> > > > 2003-03-08 15:31:57.749383 leaving dbnextrow() returning -2
> > > >
> > > > Thanks,
> > > > Andrew
> > > >
> > > > PS. The image displays perfectly if I run Apache, PHP, MSSQL
> > all on Win2K.
> > > >
> > >
> > > Can you post your PHP code? I think it's a php mis-behavior...
> > > How did you compile php under Linux? With ctlib or dblib?
> > >
> > > freddy77
> > >
> > >
> > > _______________________________________________
> > > FreeTDS mailing list
> > > FreeTDS AT lists.ibiblio.org
> > > http://lists.ibiblio.org/mailman/listinfo/freetds
> > >
> >
> > _______________________________________________
> > FreeTDS mailing list
> > FreeTDS AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/freetds
> >
> >
>
> ---------------------------------------------------------------------
> Would you like to receive faxes to your personal email address?
> You can with mBox. Visit http://www.mbox.com.au/fax
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
>




Archive powered by MHonArc 2.6.24.

Top of Page