Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
reading image from mysql

Posted by fastlife (fastlife), 24 October 2007

i am using this code with little modification like i have moved // Insert any new image into database
code to a separate file.

and reading image in a different file.  My problem is that it is not showing image instead it is showing me binary data. (I want to print it in the page every time it loads) Please help me


Posted by admin (Graham Ellis), 25 October 2007
I'm guessing that you haven't added a call to the PHP header function to set the content type, but without seeing you code that has to be a guess

Posted by fastlife (fastlife), 25 October 2007
thanks for replaying.

I am pasting piece code for you to view.

                 <td width="100%" colspan="3">
                 <p align="center"><b>
                 <font face="Verdana" size="2" color="#515151">MODIFY USER                </font></b></td>
                 <td width="8%">&nbsp;</td>
                 <td width="21%">&nbsp;</td>
                 <td width="71%">&nbsp;</td>
$gotten = @mysql_query("select * from users where user_id=$UID");
if ($row = @mysql_fetch_assoc($gotten)) {
      $bytes = $row[picture1];
} else {
       $errmsg = "There is no image in the database yet";
       $title = "no database image available";
if ($_REQUEST[gim] == 1) {
       header("Content-type: image/jpeg");
       print $bytes;
       exit ();

                                       <input type="hidden" name="txtMenuID" size="60" value="<?=$row["user_id"]?>">

                             <script language="javascript1.2">
                 <input type="hidden" name="MAX_FILE_SIZE" value="50000">
                 <td width="30%" class='style9'>Picture 1</td>
                 <td width="70%"><img src=?gim=1 width=144>
<br><input type="file" name="txtPic" size=30>

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho