On Wed, May 27, 2009 at 1:51 PM, Miller, Terion <
tmil...@springfi.gannett.com> wrote:

>
>
>
> On 5/27/09 12:49 PM, "Bastien Koert" <phps...@gmail.com> wrote:
>
> On Wed, May 27, 2009 at 1:46 PM, Shawn McKenzie <nos...@mckenzies.net
> >wrote:
>
> > Miller, Terion wrote:
> > > I am trying to get an image to display but I get nothing if done like
> > this:
> > >
> > >    <tr>
> > >             <td>Scout Photo:</td>
> > >
> > >    <td><img src="<?php echo $row['ePhoto'];?>"></td>
> > >
> > > </tr>
> > >
> > >
> > > If I just echo the field I do get the file name....
> > >
> >
> > Does the filename include the path?  Does the image with said filename
> > actually exist in that path?
> >
> > --
> > Thanks!
> > -Shawn
> > http://www.spidean.com
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> Is it an image from the db or a path to an image on the filesystem?
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
> Hi Bastien it is an image in the db.
> Thanks
> Terion
>

You can't display the image that way due to differeing headers in required
for html and images. Change your image code to call a page that specializes
in handling the images and the headers needed by changing to something like
this:

echo "<img src=\"show_image.php?id=".$rows['id']."\">\n";

where the show_image page calls the image out from the db and display it as
below

<?php
require("conn.php");
//check to see if the id is passed
if(isset($_GET['id'])) {
    $id=$_GET['id'];

    //query the database to get the image and the filetype
    $query = "select bin_data, filetype from binary_data where id=$id";

    $result = mysql_query($query);
    $row = mysql_fetch_array($result);
      {
       $data = $row['bin_data'];
       $type = $row['filetype'];
      }
      if ($type=="pjpeg") $type = "jpeg";   //handle the ms jpeg alternate
format
      Header( "Content-type: $type");
      echo $data;
}
?>
-- 

Bastien

Cat, the other other white meat

Reply via email to