By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,969 Members | 2,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,969 IT Pros & Developers. It's quick & easy.

How to read blob data from database

P: 2
i have inserted blob data in database , but i am not able to access back that data to the browser. i have php script but it does not work proprly.
our script is below
Expand|Select|Wrap|Line Numbers
  1. if ($_REQUEST[gim] == 1) {
  2.     header("Content-type: image/jpeg");
  3.     print $bytes;
  4.     exit ();
  5. }
  6.  
but it does not work correctly.
the Question is now that how i will read blob data to the browser
Thanksss
Nov 12 '07 #1
Share this Question
Share on Google+
1 Reply


ak1dnar
Expert 100+
P: 1,584
Only thing you need to set up the correct header.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $con = mysql_connect('localhost', 'root', 'dba') or die ("Could not connect to the Database");
  3. mysql_select_db('mytable', $con) or die (mysql_error()); 
  4. $query = 'SELECT content FROM blobdata';
  5. $result = mysql_query($query);
  6. while ($row = mysql_fetch_array($result)){
  7. header("Content-type: image/jpeg");
  8. echo $row['content'];
  9. }
  10. ?>
Nov 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.