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

how to fetch an image from mysql database

P: 34
i inserted an image in mysql,by using BLOB type
i wan to fetch..can anyone tell me,how to do this
Feb 16 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 4,258
Opposite of how you stored it (more or less). This is a sample:
$sql = "SELECT * FROM image WHERE image_id='image_id'";
$result = mysql_query ($sql, $conn);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
$image = $row["image"];
Header ("Content-type: $image_type");
print $image;

Ronald :cool:
Feb 16 '07 #2

Post your reply

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