Hi,
I am trying to display an image on the browser by fetching blob object data from mysql database, I am getting the binary data, the proble is it is not displaying as an image when i try to bind it as source of html img control. It is only showing a box with cross mark. Any help on this is highly appriciated.
Here is my code

hello.php

 <html>
 <head>
  <style type="text/css">
   .background { background-image:url(back.png);background-repeat:repeat-x; }
</style>
  <title>PHP Test</title>
 </head>
 <body>
 <div Class="background">
  <table style="width:100%; height:100px;">
     <tr>
       <td width="100%" align="center" height="100px">
        <!-- Banner -->
         My Page
      </td>
    </tr>
   </table>
    <table style="width:100%; height:100px;">
     <tr>
       <td>

     <img src="getImage.php" height="80" width="60" />         

   </td >
   <td width="30%" style="height:100px;">
     <!-- Image2 -->        
   </td>
   <td width="30%" style="height:100px;">
     <!-- Image3 -->
     image 3
   </td>
 </tr>
 </table>
  </div>
 </body>
</html>

and getImage.php

<?php 

mysql_connect("localhost:3308","user","pass") or die("Unable to connect to SQL server"); 
@mysql_select_db("dbwebcontents") or die("Unable to select database"); 
$result=mysql_query("select content_image from tblpagecontents where rowid=1") or die("Can't perform Query"); 

//$data=@MYSQL_RESULT($result,0,"content_image"); 

$data = mysql_fetch_array($result);

//header('Content-Length: '.strlen($data));
header('Content-type: image/jpg'); 
//header('Content-Disposition: inline; filename="add1.jpg"');

echo($data);  

?>

    Welcome to PHPBuilder!

    Your problem is that you're trying to echo $data directly, which is an array. Either output the appropriate item in that array, or don't retrieve an array at all (since you're only SELECT'ing a single column from what would appear to be a single row) by using [man]mysql_result/man instead.

    EDIT: Also, when posting PHP code, please use the board's [noparse]

    ..

    [/noparse] bbcode tags (or HTML tags for HTML code) as they make your code much easier to read and analyze.

      php code:
      $data=@MYSQL_RESULT($result,0,"content_image");
      echo($data);

      or
      $result=mysql_query("select content_image from tblpagecontents where rowid=1") or die("Can't perform Query");
      echo(@MYSQL_RESULT($result);

      both not working..
      is there anything i have to do about php setting in "ini" file. Also at the bottom of my page I am getting this text -

      No log handling enabled - turning on stderr logging Cannot find module (IP-MI😎: At line 0 in (none) Cannot find module (IF-MI😎: At line 0 in (none) Cannot find module (TCP-MI😎: At line 0 in (none) Cannot find module (UDP-MI😎: At line 0 in (none) Cannot find module (HOST-RESOURCES-MI😎: At line 0 in (none) Cannot find module (SNMPv2-MI😎: At line 0 in (none) Cannot find module (SNMPv2-SMI): At line 0 in (none) Cannot find module (NOTIFICATION-LOG-MI😎: At line 0 in (none) Cannot find module (UCD-SNMP-MI😎: At line 0 in (none) Cannot find module (UCD-DEMO-MI😎: At line 0 in (none) Cannot find module (SNMP-TARGET-MI😎: At line 0 in (none) Cannot find module (NET-SNMP-AGENT-MI😎: At line 0 in (none) Cannot find module (DISMAN-EVENT-MI😎: At line 0 in (none) Cannot find module (SNMP-VIEW-BASED-ACM-MI😎: At line 0 in (none) Cannot find module (SNMP-COMMUNITY-MI😎: At line 0 in (none) Cannot find module (UCD-DLMOD-MI😎: At line 0 in (none) Cannot find module (SNMP-FRAMEWORK-MI😎: At line 0 in (none) Cannot find module (SNMP-MPD-MI😎: At line 0 in (none) Cannot find module (SNMP-USER-BASED-SM-MI😎: At line 0 in (none) Cannot find module (SNMP-NOTIFICATION-MI😎: At line 0 in (none) Cannot find module (SNMPv2-TM): At line 0 in (none)

      How can I get rid of that too..

      Thanks

        Start by getting rid of all the "@" operators while debugging so that PHP will tell you what's wrong. (You can put them back later if you really think you need to.) In your original code, if everything worked OK up until then, you should be able to echo $data[0]; (since you are only retrieving one field). But you might need to add some defensive code to ensure that a row was actually found (mysql_num_rows()) and so forth.

          Write a Reply...