how to fetch an image from mysql database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemashiki
    New Member
    • Aug 2006
    • 34

    how to fetch an image from mysql database

    hi
    i inserted an image in mysql,by using BLOB type
    i wan to fetch..can anyone tell me,how to do this
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Opposite of how you stored it (more or less). This is a sample:
    [php]
    $sql = "SELECT * FROM image WHERE image_id='image _id'";
    $result = mysql_query ($sql, $conn);
    if (mysql_num_rows ($result)>0) {
    $row = @mysql_fetch_ar ray ($result);
    $image_type = $row["image_type "];
    $image = $row["image"];
    Header ("Content-type: $image_type");
    print $image;
    }[/php]

    Ronald :cool:

    Comment

    Working...