image does not get retrieved from database into html form using php -
getimage.php
<?php $hostname="localhost"; $username="root"; $password="tiger"; /* @var $dbhandle type */ $dbhandle = \mysqli_connect($hostname, $username, $password) or die("unable connect 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 starterveg 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 display image database html for.instead alt message appears inside html form
try in getimage.php
header("content-type:image/jpeg"); stripslashes ($row['img']); echo $row['img'];
***storing image in db not recommended.*
edit 2 >>
$itemid= (\filter_input(\input_get,'name'));
this should
$itemid= (\filter_input(\input_get,'itemid')); #as passing itemid in get
edit 3>>
you missing single quotes (') in query , causing errors
it should
$sql="select img starterveg itemid='$itemid'";
Comments
Post a Comment