471,850 Members | 996 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,850 software developers and data experts.

How to read blob data from database

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
1 7558
ak1dnar
1,584 Expert 1GB
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.

Similar topics

3 posts views Thread by Thierry | last post: by
7 posts views Thread by John | last post: by
4 posts views Thread by Ellen K | last post: by
3 posts views Thread by hamvil79 | last post: by
2 posts views Thread by Luis Mendes | last post: by
3 posts views Thread by =?Utf-8?B?ZGF2aWQ=?= | last post: by
4 posts views Thread by =?ISO-8859-1?Q?Hans_M=FCller?= | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.