Forums

PHP

This topic is locked

MS SQL and image type data

Posted 27 Dec 2006 22:22:16
1
has voted
27 Dec 2006 22:22:16 Bob Louderback posted:
Hi all,

Using php, I'm having a problem displaying images that have been inserted into an MS SQL database by MS ACCESS. That is, I have an MS Access application that users have inserted jpg files into MS SQL, and I'm trying to display them on a web page. I have 2 php files doing the work, one displays all the columns of the record (bob.php), and one is supposed to display the image itself (displayblob.php). I get the regular data, username, date/time, documnetID, etc, but the image keeps coming up with that darn little red x. Am I truncating the image data or something? Any ideas?


bob.php:

<font color=red><pre id=code><font face=courier size=2 id=code>&lt;?php
echo ("Here's your Document Data: &lt;br&gt;&lt;br&gt;";

// make the connection to MS SQL...
$db = mssql_connect("10.10.10.30", "xxxuser", "xxxxxxi1234";

// retrieve the documentID from the command line...
$Docid = $_GET['Docid'];

// Specify database...
mssql_select_db('MediciMaster');

// Build SQL statement...
$sqlText = 'SELECT * FROM Documents WHERE DocumentID = ' . $Docid;
$sql = mssql_query($sqlText);


// Start displaying the data from the row we found...
echo ("DocumentID: ";
echo mssql_result($sql,0,"DocumentID";
echo "&lt;BR&gt;";
echo ("Description: ";
echo mssql_result($sql,0,"Description";
echo "&lt;BR&gt;";
echo ("UserName: ";
echo mssql_result($sql,0,"Username";
echo "&lt;BR&gt;";
echo ("Last Modified: ";
echo mssql_result($sql,0,"Modified";
echo "&lt;BR&gt;&lt;BR&gt;&lt;HR&gt;";
echo ("&lt;img src='displayblob.php?Docid=" . $Docid . "'&gt;";
echo "&lt;BR&gt;";
?&gt;</font id=code></pre id=code></font id=red>



displayblob.php:

<font color=red><pre id=code><font face=courier size=2 id=code>&lt;?php
header('Content-type: image/jpeg;');
$db = mssql_connect("10.10.10.30", "xxxuser", "xxxxxxi1234";
$Docid = $_GET['Docid'];

// Specify database here
mssql_select_db('MediciMaster');

// Build SQL statement here
$sqlText = 'SELECT document FROM Documents WHERE DocumentID= ' . $Docid;
$sql = mssql_query($sqlText);
echo mssql_result($sql,0,"Document";
mssql_close();
?&gt;</font id=code></pre id=code></font id=red>
-Bob-

Edited by - blouderback on 27 Dec 2006 22:23:48

Reply to this topic