You have to echo a single image and only the image(no html tags) as binary
for this to work. One must also set the header from the page to the correct
mime type for the image work.

ex:

Page: displayImg.php

header('Content-Type: image/jpeg');  // set correct header, more info
on:http://us2.php.net/manual/en/function.header.php

include_once("../includes.list.php");
$ms_sql= new ms_db();
$my_sql=new Database();
    $query="select photo from cars where id=" $_GET["id"];
    $data=$ms_sql->query($query);
    while($obj = $ms_sql->objects('',$data)){
        echo $obj->photo;
    }
$data=$ms_sql->disconnect();

Page where image goes:

<html>
 <head>
 <meta http-equiv="Content-Type" content="image/jpg">
 </head>
<body>
<img src="displayImg.php?id=22">
 </body>
 </html>

Angelo



----- Original Message ----- 
From: "blackwater dev" <[EMAIL PROTECTED]>
To: <php-general@lists.php.net>
Sent: Tuesday, October 04, 2005 2:14 PM
Subject: [PHP] Re: displaying image from blog


> Sorry, meant BLOB, not blog.
>
> On 10/4/05, blackwater dev <[EMAIL PROTECTED]> wrote:
> > I am querying a MSSQL db where an jpg image is stored as a blog.
> >
> > I have this code:
> >
> > <html>
> > <head>
> > <meta http-equiv="Content-Type" content="image/jpg">
> > </head>
> > <body>
> > <?
> > //Do the query
> > include_once("../includes.list.php");
> >   $ms_sql= new ms_db();
> >   $my_sql=new Database();
> >   $query="select photo from cars where id=22";
> >   $data=$ms_sql->query($query);
> >    while($obj = $ms_sql->objects('',$data)){
> >     echo $obj->photo;
> >    }
> > $data=$ms_sql->disconnect();
> > ?>
> > </body>
> > </html>
> >
> > But when viewed I just get all the junk code:
> >
> > !1AQaq"2B'¡±Á #3RðbrÑ
> >
$4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š'""•–—˜™š¢£¤¥¦
§¨(c)ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øù
> >
> > What is wrong?
> >
> > Thanks!
> >
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to