You are here: Re: [PHP] Re: displaying image from blog « PHP « IT news, forums, messages
Re: [PHP] Re: displaying image from blog

Posted by cron on 10/21/60 11:28

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!
> >
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация