coopster

msg:1314684 | 12:08 pm on Jun 6, 2006 (gmt 0) |
Welcomme to WebmasterWorld, bhavnagadhiya. if ($row = mysql_fetch_array(mysql_query('SELECT image FROM imageMySQL'))) { $image = $row['image']; } You just assign it as you would any other variable.
|
bhavnagadhiya

msg:1314685 | 12:16 pm on Jun 6, 2006 (gmt 0) |
Thank you... its printing the binary data itself in page
|
coopster

msg:1314686 | 12:18 pm on Jun 6, 2006 (gmt 0) |
Yes, and it will unless you send the proper mime type out prior to it's display.
header("Content-type: image/jpg"); print $row['image'];
|
coopster

msg:1314687 | 12:25 pm on Jun 6, 2006 (gmt 0) |
Also, there is a thread in our PHP Forum Library [webmasterworld.com] that discusses How to convert image blob files back to image [webmasterworld.com] which you may find useful.
|
bhavnagadhiya

msg:1314688 | 12:28 pm on Jun 6, 2006 (gmt 0) |
its same thing coopster see i am displaying this templates variable only in to html page i cant use header in html page u know that... i cant use headet and print function in my tpl(html/templates)..
|
stajer

msg:1314689 | 3:27 pm on Jun 6, 2006 (gmt 0) |
You should consider changing this setup. Storing images as blobs in dbs is: 1. space inefficient; 2. resource inefficient (time to http display an image v. db query plus php process plus http) 3. and difficult to maintain. A faster/cleaner setup is to setup a file server, save the image there and just save the image location, name, size and lastupdatedatetime to the db.
|
coopster

msg:1314690 | 7:13 pm on Jun 6, 2006 (gmt 0) |
bhavnagadhiya, you are correct, but if you study the discussion given in my last post you will see how you can accomplish what you desire. You have a php script that accepts an image identifier and retrieves it from the database table. Then, at the end of that script you print out the appropriate header as well as the binary image data. You refer to this script in your <img> element in the HTML. Read the example again carefully and you will see how it is done.
|
|