image src is not displaying the page in php -
**i'm trying upload img path in database , show them in slider, problem img src not showing page assigned. can body tell me why image src not loading page.
my code below
slider.php slider has image code
:<img src='<?php echo "imagetest.php?id=$id" ?> width="200">
image path couldn't display page
imagetest.php has following code:
page not showing in img src of sliderif (empty($_get['id']) || !is_numeric($_get['id'])) { echo 'a valid image file id required display image file.'; exit; }
$imageid = $_get['id']; //connect mysql database if ($conn = mysqli_connect('localhost', 'root', 'root', 'test')) { $content = mysqli_real_escape_string($conn, $content); $sql = "select type, content images id = {$imageid}"; if ($rs = mysqli_query($conn, $sql)) { $imagedata = mysqli_fetch_array($rs, mysqli_assoc); mysqli_free_result($rs); } else { echo "error: not data mysql database. please try again."; } //close mysqli connection mysqli_close($conn); } else { echo "error: not connect mysql database. please try again."; } if (!empty($imagedata)) { // show image. header("content-type: {$imagedata['type']}"); echo $imagedata['content']; }
?>
use file_get_contents
<img src="<?php echo file_get_contents('imagetest.php?id='. $id);?>" width="200"/>
and remove header(), u don't need it.
Comments
Post a Comment