php - Unable to get the image from mysql DB -


i'm new php. have sample mysql db in have table named testdb columns id(int) , image(blob). have uploaded image testdb. uploaded successfully. following php code. variable $conn contains connection details. have html page redirects php page on submitting.

<?php $name = $_files["sample"]["name"]; echo $name . "<br/>";  $tmp_name = $_files["sample"]["tmp_name"]; echo $tmp_name . "<br/>";  $size = $_files["sample"]["size"]; echo $size . "<br/>";  $contents = file_get_contents($tmp_name); $htmlen = htmlentities($contents); $cont = mysql_real_escape_string($contents);  $query = "insert testdb(image)       values ('$cont')"; $dbquery = mysql_query($query, $conn); if($dbquery){     echo "successfully inserted";     } else{     echo "could not inserted" . mysql_error();     } ?> 

i trying image following code. showing string characters rather image. far know should work fine.

<?php $query = "select image, id     testdb "; $dbquery=mysql_query($query , $conn); if(! $dbquery){     echo "could not selected data database. " . mysql_error(); } while( $row = mysql_fetch_array($dbquery) ){     $decodeimg = html_entity_decode($row["image"]); echo "<img src= $decodeimg/><br/> hellow orld <br/>"; } ?> 

could me this. in advance.

instead of storing actual image in database (which redundant because stored on server too); why don't store path image string, query string db , append 'src' attribute php.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -