所以我有这样的代码的HTML:如何显示我的网页中保存在Mysql中的图片为中Blob?
<img src="imagescript.php?id=1">
,我有这个代码在imagescript.php:
<?php
$servername="localhost";
$username="root";
$conn= mysql_connect($servername,$username)or die(mysql_error());
mysql_select_db("licitatii",$conn);
$sql="select picture from auctions where auction_id='$_GET[id]'";
$result=mysql_query($sql,$conn) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$image = $row['picture'];
header("Content-type: image/jpeg");
print $image;
?>
我已经使用这个指令,从互联网上,但我的形象没有按” t显示。
是否有可能我错误地上传了图像?
我用<输入名称=“regphoto”类型=“文件”>中的方法=“POST”的形式,然后在表格中插入$ _ POST [regphoto]
如果它可以帮助你,这里的PHP脚本我用来插入照片点击提交按钮后:
$ SQL =“插入到拍卖(auction_id
,owner_id
,parent_category_id
,title
,description
,picture
,postage
,,buyout_price
,end_date
)值(NULL, '$ OWNERID', '$ parentcategoryid',“$ _ PO ST [regtitle]”, '$ _ POST [regdescription]', '$ _ POST [regphoto]', '$ _ POST [regpostage]', '$ _ POST [regstartingprice]', '$ _ POST [regbuyoutprice]', '$到期' )“;
就像你看到的,我插入到“图片”列(类型MEDIUMBLOB)值$ _ POST [regphoto]
你指的是什么代码? – AllisonC 2011-06-16 15:38:20
@AllisonC对不起,我不知道我不得不缩进空格来查看代码 – ionescho 2011-06-16 15:51:17
如果你在标题前做了一个var_dump($ image),你会得到任何数据吗? – AllisonC 2011-06-16 15:53:30