suma237 Posted February 17, 2009 Share Posted February 17, 2009 how to retrieve image(BLOB) from mysql database? Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 17, 2009 Share Posted February 17, 2009 1. SELECT it 2. Set up headers according to image type 3. Echo blob Quote Link to comment Share on other sites More sharing options...
suma237 Posted February 17, 2009 Author Share Posted February 17, 2009 could you please check this code #connecting to mysql server $link = mysql_connect(MyHost,MyUser,MyPass) or die("Error while connecting".mysql_error()); mysql_select_db(MyDataBase); $fetch_id="select id from tbl_images"; $result_id=mysql_query($fetch_id); while($row_fetchid=mysql_fetch_array($result_id)) { $id1=$row_fetchid['id']; $fetch_query="select image,imagename from tbl_images where id=".$id1; $result=mysql_query($fetch_query); $row_fetch=mysql_fetch_assoc($result); print "Image Name:".$row_fetch['imagename']; $image_disp=$row_fetch['image']; header("Content-type:image/jpeg"); print $image_disp; } [code] Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 17, 2009 Share Posted February 17, 2009 print "Image Name:".$row_fetch['imagename']; You can not echo (or print) anything else. Quote Link to comment Share on other sites More sharing options...
suma237 Posted February 17, 2009 Author Share Posted February 17, 2009 ok.but the loop is not working.It will display only one record. why? Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 17, 2009 Share Posted February 17, 2009 You can't display multiple images this way. This wouldn't make any sense. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.