0
 $dbc=mysqli_connect('localhost','root','','db')

$query="SELECT Binfile, Filetype FROM imagetable where imgid='$imgid'" ;
$result=mysqli_query($dbc,$query);
$row=mysqli_fetch_assoc($result);

$image=$row['Binfile'];
header("Content-type:".$row['Filetype']);

echo $image;  

This is the code which I am using to display the image. But it is giving an error like

The image “http://lacalhost//viewimage.php?imgid=1” cannot be displayed because it contain errors.

Help me to remove this error and display the image…

I wonder if I can use as echo'img src=' type to display.

Freelancer
  • 836
  • 1
  • 14
  • 47
125fura
  • 383
  • 2
  • 13
  • do you have `$imgid = $_GET['imgid']`? – Sean Dec 22 '14 at 05:26
  • Yes,it just above the query – 125fura Dec 22 '14 at 05:27
  • 1
    Check the piece of code where the images go to the db. The source may be encoded. Then you should decode it before echoing. – Ruben Kazumov Dec 22 '14 at 05:30
  • do you have error reporting turned on? `ini_set('display_errors',1); error_reporting(E_ALL);` – Sean Dec 22 '14 at 05:30
  • what's the output of `$row['Filetype']` ? what's the output of `$row['Binfile'];`? please check it by yourself. Please mind you will not see any errors or messages because of `header("Content-type:"`. r – Peter Dec 22 '14 at 09:52
  • Check this link http://stackoverflow.com/questions/20556773/php-display-image-blob-from-mysql – Yash Dec 22 '14 at 10:38

0 Answers0