Reading an Image file from a mysql database using php -
i trying display image, webpage displays encoding stuff instead. below code:
<?php ob_start();?> // html markups goes here <?php include 'login.php'; if(isset($_get['productid'])){ $productid = $_get['productid']; $sql = "select tyre_image tyres product_id = '$productid'"; $result = mysql_query($sql) or die(mysql_error()); header("content-type :image/jpg"); echo mysql_result($result,0); } ob_end_flush(); ?>
i using $_get associative array($_get['variable']) product id via link on page.
how fix this?
i had no idea content-type
header picky, change spacing around colon (and image/jpg
should image/jpeg
):
header("content-type: image/jpeg");
per answer below, agree - fix assumes script used displaying image in html, ala <img src="path/to/your/image.php?productid=123" />
.
further light reading on image/jpeg
mime type spec here.
Comments
Post a Comment