php+mysql显示不出图片,这是为什么
--- index.php
<?php
include('conn.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equive="Content-Type" content=text/html charset=utf-8>
<title> </title>
</head>
<body>
<form method='post' action='upload.php' enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" name="submit" value="上传" />
</form>
<!-----------显示图片--------------------->
<table>
<?php
$ret = @mysql_query('select * from image order by id desc');
if ($ret) {
while ($row = mysql_fetch_array($ret)) {
?>
<tr>
<td style='width:170px;'>
<img src="image.php?id=<?php
echo $row[id];
?>" width="170" height="150" border="0">
<div style='text-align:center;'><?php
echo $row['name'];
?></div>
<?php
echo $row['date'];
?>
</td>
</tr>
<?php
}
}
?>
</table>
<!-----------/显示图片--------------------->
</body>
</html>
--- image.php
<?php
include('conn.php');
$id = $_GET['id'];
$sql = "select * from image where id='$id'";
$result = @mysql_query($sql, $conn);
if (!$result)
die("读取图片失败!");
$num = mysql_num_rows($result);
$num = mysql_affected_rows($result);
if ($num < 1)
die("暂无图片");
$data = mysql_result($result, 0, 'pic');
$type = mysql_result($result, 0, 'type');
mysql_close($id);
echo alert(mysql_close($id));
Header("Content-type: $type");
echo $data;
?>
--- upload.php
<?php
include('conn.php');
if ($_POST['submit']) {
if ($_FILES['image']['size']) {
$names = $_FILES['image']['name'];
$arr = explode('.', $names);
$name = $arr[0]; //图片名称
$date = date('Y-m-d H:i:s'); //上传日期
$fp = fopen($_FILES['image']['tmp_name'], 'rb');
$type = $_FILES['image']['type'];
if (!$fp) {
showInfo('读取图片失败!');
} else {
$image = addslashes(fread($fp, filesize($_FILES['image']['tmp_name'])));
if ($image) {
$q = "insert into image (name, pic, type, date) values ('$name','$image','$type','$date')";
$result = @mysql_query($q);
if ($result) {
showInfo('上传成功!');
} else {
showInfo('上传失败!');
}
} else {
showInfo('请选择要上传的文件!');
}
}
} else {
showInfo('请选择要上传的文件!');
}
}
function showInfo($info)
{
echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
echo "<meta http-equiv='refresh' content='1;url=index_tp.php'>";
echo "</head>";
echo "<body>" . $info . "……</body>";
echo "</html>";
}
?>
就是不显示图片,求大神指导