Getimage.php
<?php
$hostname="localhost";
$username="root";
$password="tiger";
/* @var $dbhandle type */
$dbhandle = \mysqli_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
/* @var $select type */
$select= \mysqli_select_db($dbhandle,"sample")
or mysqli_error($dbhandle);
/* @var $itemId type */
$itemId= (\filter_input(\INPUT_GET,'name'));
$sql="select img from starterveg where itemId=$itemId";
$res2=mysqli_query($dbhandle,$sql);
$row= mysqli_fetch_assoc($res2);
mysqli_close($dbhandle);
header("Content-type: image/jpeg");
echo $row['img'];
?>
<body>
<img src="Getimage.php?itemId=oepsv1086" alt="image" id="img1">
</body>
> I'm not able to display the image from database into the html for.Instead the alt message only appears inside the html form
Try in your getimage.php
header("Content-type:image/jpeg");
stripslashes ($row['img']);
echo $row['img'];
***storing image in DB is not recommended.*
EDIT 2 >>
$itemId= (\filter_input(\INPUT_GET,'name'));
this should be
$itemId= (\\filter_input(\\INPUT_GET,'itemId')); #as you are passing itemid in get
EDIT 3>>
You were missing single quotes (') in where query , that was causing errors
it should be
$sql="select img from starterveg where itemId='$itemId'";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.