The problem is that the header for images needs to be set correctly for the
binary data to be show correctly. Example below is for mysql, so you should
only need to change the image header and the db calls to reflect mssql...
Here are the two working pages (tested my machine (xp, apache2, php4.3.9
In the areas for the db query you will see the notation
$result = connect(sql);
connect is a custom function to handle all db interatction that is separate
from the pages and included in the conn.php file. There is another example
with that function in my previously posted code samples.
// you may have to modify login information for your database server
$query = "select description, id from binary_data ";
$result = connect($query);
while ($rows = MYSQL_FETCH_ARRAY($result))
echo "<img src=\"show_image.php?id=".$rows['id']."\">\n";
//check to see if the id is passed
$query = "select bin_data, filetype from binary_data where id=$id";
$result = connect($query);
$row = mysql_fetch_array($result);
$data = $row['bin_data'];
$type = $row['filetype'];
if ($type=="pjpeg") $type = "jpeg";
Header( "Content-type: $type");
From: [EMAIL PROTECTED]
Subject: [PHP-DB] Displaying bitmap images from an MS SQL db in a php page
Date: Wed, 21 Dec 2005 10:17:11 -0500
I am using an MS SQL db to store records which include an column of type
"image". I can get the image into the table correctly, and I can get it
out and make a .bmp file out of it, but I would like to pull the bitmap
out of the column and display it directly on a page as an image. I have
been going through the 'Image' section of the documentation on the php
site, but I am not sure what approach to take. Anyone accomplished this,
or something similar?
The contents of this e-mail and its attachments are confidential and may be
privileged. If you are not the intended recipient of this e-mail, please
notify IDX immediately (by return e-mail to either the sender or
[EMAIL PROTECTED]), destroy all copies of this message along with any
attachments and do not disclose, copy and/or distribute the contents. The
views expressed in this message are those of the author and not necessarily
those of IDX. In the absence of a prior written agreement with you
authorizing commitments of IDX via e-mail, the above message shall not bind
IDX, unless from a duly authorized officer of the company in a context
indicating an intention to bind the company.
This e-mail and its attachments are protected by copyright and other laws.
(c) IDX Systems Corporation 2005. All rights reserved. IDX is a
registered trademark of IDX Investment Corporation.
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php