Re: Re: displaying image from blog

From: Date: Tue, 04 Oct 2005 17:57:40 +0000
Subject: Re: Re: displaying image from blog
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-223618@lists.php.net to get a copy of this message
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" <blackwaterdev@gmail.com> 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 <blackwaterdev@gmail.com> 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! > > >

« previous php.general (#223618) next »