如何在保存为Mysql的Mysql中显示网页图片?

| 所以我在HTML中有以下代码:
 <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;
 ?>
我从互联网上的说明中使用了此图片,但是我的图片没有显示。 我是否可能错误地上传了图像? 我以方法= \“ POST \”的形式使用<输入名称= \“ regphoto \”类型= \“文件\”>,然后将$ _POST [regphoto]插入表中 如果有帮助,请点击提交按钮后,使用以下php脚本插入照片: $ sql = \“插入拍卖(
auction_id
owner_id
parent_category_id
title
description
picture
postage
starting_price
buyout_price
end_date
)值(NULL,\'$ ownerid \',\'$ parentcategoryid \',\'$ _POST [regtitle] \',\'$ _ POST [regdescription] \',\'$ _ POST [regphoto] \',\'$ _ POST [regpostage] \',\'$ _ POST [regstartingprice] \',\'$ _POST [regbuyoutprice] \',\'$ expiration \')\“; 如您所见,我在\“ picture \”列(类型mediumblob)中插入了值$ _POST [regphoto]     
已邀请:
        一些评论可能会有所帮助: 您可能需要使用密码登录mysql服务器(尽管不一定...)。 您需要保护代码免受sql注入攻击,在这种情况下,最简单的方法是类似
$id = (int) $_GET[id]
并在查询中使用
$id
。 您还必须张贴用于插入图像的php代码,因为插入
$_POST[photo]
听起来是错误的:您需要
$_FILES[\'photo\']
,这是一个数组,请参见手册。     

要回复问题请先登录注册