我该如何显示它? 如何从数据库中获取图像并使用PHP查看? [关闭]

i have stored an image in the mysql database. but i don't know how to retrieve it back from the database. my php code

<?php
error_reporting(E_ERROR);
$con=mysql_connect("localhost","root","");
mysql_select_db("insidevit",$con);
$data=mysql_query("select * from image",$con);
$extract=mysql_fetch_assoc($data);
$image=$extract['image'];
//header("Content-type:image/jpeg");
//echo $extract['image'];
//echo $extract->image;
echo "<img src='".$image."' width=175 height=175>";
?>

I don't know how to display it. Someone tell me how to do it? I have tried the header() but it was showing some error. is there any way to show it

i stored the image like this.. create table image(image blob); insert into image values(load_file('e:/use/1.jpeg'));

you have upload image in some folder an then save its path into database , when you did that you can use that in some html tag like this: echo "<img src='".$image['path']."' width=175 height=175>"

first move image in specific folder then stored path in database like

  move_uploaded_file($_files['fu']['tmp_name'],"image/".$_files['fu']['name']);
  $image="image/".$_files['fu']['name'];
  $insert="insert into image(filename) values('$image')";

and then fetch data from that table and use it in img tag

You can store only name of image in database not image itself. The image will stored in your website folder or at root of the folder.

code will like this

echo "<img src='yourFolderName/".$image."' width=175 height=175>"

make sure that you have uploaded image in particular folder, if you move image in folder using move_uploaded_file(); then give folder name in <img src=""> tag

as echo "<img src=folder_name/'".$image."' width=175 height=175>";

this might help you : file uploading with php mysql

i have got the answer. i stored correctly into the database and retrieved i made mistake in displaying it. And i found the way to display it.

<?php
error_reporting(E_ERROR);
$con=mysql_connect("localhost","root","");
mysql_select_db("insidevit",$con);
$data=mysql_query("select * from image",$con);
$extract=mysql_fetch_assoc($data);
$image=$extract['image'];
header("Content-type:image/jpeg");
//echo mysql_result($data,0);
echo $extract['image'];
?>

This header() worked. Thanks for the people who reduced my reputation without answering the question