Forums
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><?php
echo ("Here's your Document Data: <br><br>"
// 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 "<BR>";
echo ("Description: "
echo mssql_result($sql,0,"Description"
echo "<BR>";
echo ("UserName: "
echo mssql_result($sql,0,"Username"
echo "<BR>";
echo ("Last Modified: "
echo mssql_result($sql,0,"Modified"
echo "<BR><BR><HR>";
echo ("<img src='displayblob.php?Docid=" . $Docid . "'>"
echo "<BR>";
?></font id=code></pre id=code></font id=red>
displayblob.php:
<font color=red><pre id=code><font face=courier size=2 id=code><?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();
?></font id=code></pre id=code></font id=red>
-Bob-
Edited by - blouderback on 27 Dec 2006 22:23:48