php_mysql问题图像从数据库显示

时间:2011-02-20 21:18:25

标签: php mysql image-processing

我正在尝试使用PHP&amp ;;来显示我的数据库中的图像。 MySQL的。我已经在互联网上搜索了如何做到这一点,我把它与我找到的代码绑在一起,但屏幕上出现的唯一一件事是文件损坏或类似的东西。

我的代码是:

<?php    
if( ( isset($_POST['submitdisplay'] ) )&&( $_POST['pwdADMIN']=="admin1986"))
{
    $findm = mysql_query("SELECT idmeasure, vmanufacturer, vmodel, vtype, volume, yearofvehicle, motion, timereact,time_0_18m, 
    time_0_100m, time_0_200m, time_0_300m, time_0_400m, speedexit, time_0_100km, typeoftyre, dmeasure, temperature, sceneryofmeasure, 
    horsepower, vehicleforce, drivername, email, emailappearornot, sitelink, stock, weightofvehicle, videoofvehicle, comments, password  
    FROM measurementofvehicle WHERE approved='NO'");

    echo '<table border="2" style="width: 100%; align: center;" bordercolor="red">';
    $tmpid="";

    while ($row = mysql_fetch_array($findm, MYSQL_NUM))
    {
        echo '<tr>';                   
        echo '<td align="center"><font color="red">';echo $row[0];echo '</font></td>'; 
        $tmpid=$row[0];
        echo '<td align="center"><font color="red">';echo $row[1];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[2];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[3];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[4];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[5];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[6];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[7];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[8];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[9];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[10];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[11];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[12];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[13];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[14];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[15];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[16];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[17];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[18];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[19];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[20];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[21];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[22];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[23];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[24];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[25];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[26];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[27];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[28];echo '</font></td>'; 
        echo '<td align="center"><font color="red">';echo $row[29];echo '</font></td>';  

        $idr = "";

        $getidr = "SELECT fidRtime FROM measurementofvehicle_receiptoftime_receiptofforce_imageofvehicle WHERE fidmeasure='$tmpid'";

        $r1 = mysql_query($getidr)or die(mysql_error());
        while($srow = mysql_fetch_array($r1) )
        { 
            $idr=$srow['fidRtime'];
        }    
        echo "$idr";
        echo "<img src=\"GetImage.php?id=$idsr\">\n";
        echo '</tr>';       
   }        
   echo '</table>';                
}
?>

我从另一个表中检索图像的id,

$Receiptoftime = "CREATE TABLE Receiptoftime( 
        idRtime INT NOT NULL AUTO_INCREMENT,
        nameRtime VARCHAR(30) NOT NULL,
        typeRtime VARCHAR(30) NOT NULL,
        sizeRtime INT NOT NULL,
        contentRtime MEDIUMBLOB NOT NULL,
        PRIMARY KEY(idRtime)
    ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";

idRtime是我需要从表中检索存储图像的ID。

该表是

$Receiptoftime = "CREATE TABLE Receiptoftime(
        idRtime INT NOT NULL AUTO_INCREMENT,
        nameRtime VARCHAR(30) NOT NULL,
        typeRtime VARCHAR(30) NOT NULL,
        sizeRtime INT NOT NULL,
        contentRtime MEDIUMBLOB NOT NULL,
        PRIMARY KEY(idRtime)
    ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";

我发现的代码我发现我必须编写一个生成图像的脚本然后使用标记图像,这样我就无法获得图像。生成该图像的脚本是

<?php
    error_reporting(0);
    $connect=mysql_connect("localhost","username","password") or die(mysql_error());
    mysql_select_db("dragtimesgr") or die(mysql_error());

    $id=addlashes($_REQUEST['id']);

    $image=mysql_query("SELECT * FROM receiptoftime WHERE idRtime='$id'")or die(mysql_error());
    $image=mysql_fetch_assoc($image);
    $image=$image['contentRtime'];

    header("Content-type: image/jpeg");

    echo $image;
?>
你能帮帮我吗?屏幕上出现的唯一内容是图标,似乎已被打破。我无法理解我做错了什么。

1 个答案:

答案 0 :(得分:0)

您可以直接从浏览器调用图片脚本,例如在浏览器的位置栏中键入http://host/path/GetImage.php?id=1或其他内容?

(另外,你需要修复那个脚本,因此它不是一个如此大的注入攻击目标!)

相关问题