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.*

reference

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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -