hmbargi
asked on
Get image from MYSQL database
Hi,
I'm doing php coding and would like to know how to get images from MYSQL database.
I inserted a field( flag ) with BLOB data-type in countries table ( catid, catname, flag) but having problem fetching those images from DB. I tried to fetch but it gave me meaningless representation like this:
Here are the functions that I'm working on:
I'm doing php coding and would like to know how to get images from MYSQL database.
I inserted a field( flag ) with BLOB data-type in countries table ( catid, catname, flag) but having problem fetching those images from DB. I tried to fetch but it gave me meaningless representation like this:
HDR\r¨f pHYsšœ OiCCPPhotoshop ICC profilexÚSgTSé=÷ÞôBKˆ€”KoR RB‹€‘&*! Jˆ!¡ÙQÁEEÈ ˆŽŽ€ŒQ,Š Øä!¢Žƒ£ˆŠÊûá{£kÖ¼÷æÍþµ×>ç¬ó³ÏÀ–H3Q5€©BàƒÇÄÆáä.@ $p³d!sý#ø~<<+"À¾xÓÀM›À0‡ÿêB™\€„Àt‘8K€@zŽB¦@F€˜&S `ËcbãP-`'æÓ€ø™
Here are the functions that I'm working on:
function get_countries() {
// query database for a list of countries
$conn = db_connect();
$query = "select catid, catname, flag from countries";
$result = @$conn->query($query);
if (!$result) {
return false;
}
$num_cats = @$result->num_rows;
if ($num_cats == 0) {
return false;
}
$result = db_result_to_array($result);
return $result;
}
function display_countries($cat_array) {
if (!is_array($cat_array)) {
echo "<p>No countries currently available</p>";
return;
}
echo "<ul>";
foreach ($cat_array as $row) {
$url = "show_cat.php?catid=".$row['catid'];
$title = $row['catname'].$row['flag'];
echo "<li>";
do_html_url($url, $title);
echo "</li>";
}
echo "</ul>";
echo "<hr />";
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.