I am unable to view pictures (jpeg) from a MSSQL Server 2005 database (BLOB field), no image is displayed on the web page (red X displayed).
Also as a troubleshooting step, I displayed the content of the BLOB field and got some characters which I dont understand.
Picture type: JPEG
PHP version: 5.3.0
OS: Windows XP
Browser: Internet Explorer (IE) 6
MS SQL Server version: 2005
I am connecting to the MS SQL server through an ODBC driver (SQL Server)
Can someone please help? See the PHP code below...
------------------------
<?php
// Calls the GETPIC script
$s="getpic.php";
echo "<img src='".$s."'>";
?>
--------------------------
<?php
// GETPIC script
$picid='252';
/* MS SQL Server */
$connectionMSSQL = odbc_connect("Driver={SQL Server};Server=$myServer;Database=$myDatabase", $myUser, $myPass) or die ("Unable to connect");
if ($connectionMSSQL) {
$result = odbc_exec($connectionMSSQL, "SELECT MMOBJS.LNL_BLOB AS IMAGE FROM EMP, UDFEMP, TITLE, CITYDB, MMOBJS WHERE EMP.ID='".$picid."' AND EMP.ID=UDFEMP.ID AND UDFEMP.TITLE=TITLE.ID AND CITYDB.ID=UDFEMP.CITYDB AND EMP.ID=MMOBJS.EMPID AND MMOBJS.OBJECT=1 AND MMOBJS.TYPE=0 ORDER BY EMP.LASTNAME, EMP.FIRSTNAME, EMP.ID");
} else {
die("Error");
}
while ($row = odbc_fetch_array($result)) {
// Declare variables and assign values
$cMyIMAGE=$row['IMAGE'];
break;
}
// display picture
header("Content-Type:image/jpeg");
echo $cMyIMAGE;
?>
-----------------
ALSO: This is the first part of what's displayed (echo) when I view the contents of the BLOB field in IE (I am not using the header command here, just viewing the BLOB contents):
ÿØÿàJFIF––ÿþ"LENEL OnGuard Chromakey=24,30,30ÿÛ„ $.' "+"(6(+/1343&8<82<.231 1!!11111111111111111111111111111111111111111111111111ÿÄ¢ }!1AQa"q2?‘¡#B±ÁRÑð$3br‚ %&'()
Also as a troubleshooting step, I displayed the content of the BLOB field and got some characters which I dont understand.
Picture type: JPEG
PHP version: 5.3.0
OS: Windows XP
Browser: Internet Explorer (IE) 6
MS SQL Server version: 2005
I am connecting to the MS SQL server through an ODBC driver (SQL Server)
Can someone please help? See the PHP code below...
------------------------
<?php
// Calls the GETPIC script
$s="getpic.php";
echo "<img src='".$s."'>";
?>
--------------------------
<?php
// GETPIC script
$picid='252';
/* MS SQL Server */
$connectionMSSQL = odbc_connect("Driver={SQL Server};Server=$myServer;Database=$myDatabase", $myUser, $myPass) or die ("Unable to connect");
if ($connectionMSSQL) {
$result = odbc_exec($connectionMSSQL, "SELECT MMOBJS.LNL_BLOB AS IMAGE FROM EMP, UDFEMP, TITLE, CITYDB, MMOBJS WHERE EMP.ID='".$picid."' AND EMP.ID=UDFEMP.ID AND UDFEMP.TITLE=TITLE.ID AND CITYDB.ID=UDFEMP.CITYDB AND EMP.ID=MMOBJS.EMPID AND MMOBJS.OBJECT=1 AND MMOBJS.TYPE=0 ORDER BY EMP.LASTNAME, EMP.FIRSTNAME, EMP.ID");
} else {
die("Error");
}
while ($row = odbc_fetch_array($result)) {
// Declare variables and assign values
$cMyIMAGE=$row['IMAGE'];
break;
}
// display picture
header("Content-Type:image/jpeg");
echo $cMyIMAGE;
?>
-----------------
ALSO: This is the first part of what's displayed (echo) when I view the contents of the BLOB field in IE (I am not using the header command here, just viewing the BLOB contents):
ÿØÿàJFIF––ÿþ"LENEL OnGuard Chromakey=24,30,30ÿÛ„ $.' "+"(6(+/1343&8<82<.231 1!!11111111111111111111111111111111111111111111111111ÿÄ¢ }!1AQa"q2?‘¡#B±ÁRÑð$3br‚ %&'()