Page 1 of 1

blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 9:12 am
by gma43
Hello everyone.

Thank you in advance for a possible answer.

About PHP 5.2.8, blob images not displaying

We use to run php 4.
We upgraded to 5.2.8 and since then the blob images we are pulling are displayed as text (I verified by commenting the header ("Content-type: image/jpeg")=>nothing change);
I can add that firefox cannot display what you can see below, the extract comes from IE.
I can also add that depending on vista or XP the characters in the "text" you can see below are different.

1 SQL OK, we continue
ÿØÿá!þExifII* z€ ¨(2°i‡Äp CanonCanon PowerShot SX100 IS´´2007:11:12 09:52:54 š‚J‚R'ˆÈ0220Zn‘‘‚’ Š’’’ š’¢’ ’ ’ª|’h ²†’ 0100 € à " ¢X ¢` ¢¢£¤¤¤¤h ¤( 2007:11:12 09:52:542007:11:12 09:52:54ª k k ,è0hp"x¼ÈètB ” )p&0˜ø E "Ъ #J $NR %î 'ü ( Ð-`ÿÿÈ@ ÿÿÿ`êpèkÀÿÿÀ À ÿÿÿÿÿÿ,æ­DÀqkª €eªúIMG:PowerShot SX100 IS JPEGFirmware Version 1.00Polycorû›`0þ€J SSS0@ŠÿÿÿSSÂbvþÿÿ/bvþÿÿÍ5BbrþÿÿeØ@0S“Šÿÿÿöÿÿÿ@±@ŒÊÿÿ¢@õ¾dÄ,ûû >2òw` €àdd Š €à€œ¬ƒ*éÅ—+à\3ƒU`ûeII*²R980100€àÄ áS©À À ¾ Æ (ôZ ´´

Thank you

Re: blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 9:30 am
by gma43
Forgive me , I forgot to say that we are pulling from mssql. Thanks

Re: blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 9:40 am
by McInfo
Are you using imagecreatefromstring() and imagejpeg() to output the image or just sending the data straight from the database to the browser?

Edit: This post was recovered from search engine cache.

Re: blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 9:47 am
by gma43
mc info Thank you for helping

Please note that I tried to create the image from the string like you wrote without result (we use such a routine elsewhere in our apps)

I have a two files (I built a simpler env to try to debug that): 1 "prepare the image", the other display the image.

//First File-----------------------------------------

Code: Select all

 
<?php 
 
if (isset($_GET['imgid']))
    $imgid=$_GET['imgid'];
else 
    $imgid='';
    
//Serveur SQL parameters to connect
$dbserver = "xxx.xxx.xx.x";
// user Login SQL
$dbuser = "xxxxxxxx";
// password SQL
$dbpass = "xxxxxx";
// database name
$dbname = "xxxxxx";
 
 
echo $imgid.'<br />';
 
echo $dbserver.'<br />';
echo $dbuser.'<br />';
echo $dbpass.'<br />';
echo $dbname.'<br />';
echo '1';
 
?>
<html>
<body>
<?php
$dbconn = mssql_connect($dbserver,$dbuser,$dbpass); 
mssql_select_db($dbname, $dbconn); 
 
$result = mssql_query("SELECT BLOB_IMAGE FROM GR_IMAGES WHERE CLE_IMAGE='90080066-15'"); 
//$result = mssql_query("SELECT BLOB_IMAGE FROM GR_IMAGES WHERE CLE_IMAGE='".$imgid."'"); 
 
if($result===false){
    print 'SQL wrong, we stop here<br />';
}else{
 
    print 'SQL OK, we continue<br />';
    header ("Content-type: image/jpeg");
    
    $img=mssql_fetch_row($result); 
    
    //echo $img[0];
    print $img[0];
                                                                                            
    //$img = mssql_fetch_assoc($result);  
    //print $img['BLOB_IMAGE'];
    //echo $img['BLOB_IMAGE'];
    //echo "<img src='$img[0]' />";
 
 
}
 
mssql_close($dbconn); 
 
?>
</body>
 
</html>
 
//Second File-----------------------------------------

Code: Select all

 
<?php /* Created on: 4/17/2009 */ ?>
<html>
<body>
2
<p><img src="atestcreate.php?imageid=90080066-15" /></p>
</body>
</html>
 

Re: blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 10:10 am
by McInfo
Take all of the HTML, "echo"s, and "print"s out of the first file.

Edit: This post was recovered from search engine cache.

Re: blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 10:51 am
by gma43
Thanks again. It is the same, I just get that little white square with a red cross in it. no change. I believe that we will go back to an earlier version.

Re: blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 12:25 pm
by gma43
we went back to where we were (php 4.3.3) and the problem is the same. Thanks

Re: blob images displayed as text under php 5.2.8

Posted: Fri Apr 17, 2009 1:15 pm
by McInfo
In your browser, if you go directly to <your_path_here>/atestcreate.php?imageid=90080066-15, do you see any error messages?

Also, in the first file, make sure you took out everything that is not inside the PHP tags, including any invisible characters like line breaks and spaces.

Edit: This post was recovered from search engine cache.