Skip to Content.
Sympa Menu

freetds - Re: [freetds] TDS wants to show me raw hex via PHP from MSSQL2k

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Eddie Johnson <fast_eddie_007 AT yahoo.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] TDS wants to show me raw hex via PHP from MSSQL2k
  • Date: Wed, 6 Aug 2003 08:55:25 -0700 (PDT)

Mario, thanks for the clues....I needed to pack it not unpack it as for some
reason a layer of code somewhere is converting it to HEX as it comes out....

so ....
$row = mssql_fetch_row($dbr) ;
Header( "Content-type: image/jpeg" );
$data = $row[0];
// echo "size is .... " . sizeof($data) . " xxx";
$img2 = pack("H*" , $data);

?>
<? echo $img2;?>

seems to do the trick.... would be nice to just shoot it out without the pack
like can be done via ODBC.

But it works,

Many thanks,
Eddie J.

--- Mario.Tschursch AT ic3s.de wrote:
> there is another thing:
> MS SQL stores images as hex starting with 0x
>
> to get raw image data u have to unpack the data coming from MS SQL server
>
> -- begin code
> $sql = " select imLarge from image where cCompanyID = '10CC-EAFH-6E59' and
> ititlenum = $id ";
> // echo "sql is $sql for now";
> $dbh= mssql_connect( $db , $user , $pass );
> $dbr = mssql_query( $sql , $dbh );
> $row = mssql_fetch_array($dbr) ;
> $rawdata = join('',unpack("H*",substr($row['imLarge'],2)));
>
> Header( "Content-type: image/jpeg" );
>
> ?>
> <img src="<? echo $rawdata; ?>" >
> -- end code.
>
> Mario Tschursch
> Entwickler
>
> IC3S Information, Computer und Solartechnik AG
> Postfach 1128, 25442 Quickborn, Germany
>
> Telefon: +49.4106.655-402
> Telefax: +49.4106.637-101
> E-Mail Mario.Tschursch AT ic3s.de
> Web http://www.ic3s.de/
>
> Vorstand: Jan Behrmann (Vorsitzender), Stefan Fehlauer
> Aufsichtsrat: Sven Niklasson (Vorsitzender)
> Dresdner Bank (200 800 00), Kto. 0123 9582 00
> Commerzbank (200 400 00), Kto. 8540 288
> Amtsgericht Pinneberg HRB 4477
> UST.IdNr. DE184532766
> _______________________________________________
> 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