Hi folks-
I'm trying to display images from a remote mssql 7 database. The images are all jpg's stored in a blob field. This is the code I've tried, but it isn't working. If anyone has an advice it would be greatly appreciated. Thanks!
<?
header("Content-type: image/jpg");
$hostname = "foo.foo.com";
$username = "foo";
$password = "foo";
$dbName = "mlsnhphoto";
MSSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED
TO RESPOND.");
mssql_select_db($dbName) or DIE("Table unavailable");
$query = "SELECT * FROM mls_photo WHERE id=511155";
$result = MSSQL_QUERY($query);
$i=0;
echo mssql_result($result,$i,"large_photo");
exit;
?>
Here's some asp code that accomplishes the task...
<%'ShowPicture.asp
'Read in the image from the database
set con = server.createobject("adodb.connection")
con.open "Driver=SQL Server;SErver=123.abc.com;UID=boo;PWD=boo;database=mlsnhsql;"
set rs = server.createobject("adodb.recordset")
rs.open "SELECT large_photo FROM mls_photo WHERE id="& request("mls"), con
'Set the ContentType to image/jpeg
Response.ContentType = "image/jpeg"
'Send the binary bits to the browser
Response.BinaryWrite(rs("large_photo"))
%>