我已经尝试了几个小时了,仍然没有运气。一旦图像被插入到数据库中,但是当我从数据库中进入“选择”时,所有图像都被“破坏”。我正在使用2个文件,即getimage.php和我希望所有图像都出现的文件。

查看所有图像

//Connecting Is Here
$SQL = "SELECT * FROM animals LIMIT 50";
$res = mysql_query($SQL);
$numRows = mysql_numrows($res);
$i =0;
while($i < $numRows){
    ?>
    <table width="600" class="blue">
        <tr>
            <td class="blue">
                <p class="white"><?php echo $_GET['ImageId']?><p>
            </td>
        </tr>
        <tr>
            <td class="lightblue">
                <br>
                <div align="center">
                    <img width="550" src="getimage.php?ImageId=<?php echo mysql_result($res, $i, "ImageId"); ?>"/>
                </div>
            </td>
        </tr>
    </table>
    <br>
    <?php
    $i++;
}
?>


GetImage.php

if (IsSet($_GET['ImageId'])){
     $gotten = mysql_query("SELECT  `Image` FROM  `animals` WHERE  `ImageId` LIMIT 0 , 30 = ".$_GET['ImageId']);
     header("Content-type: image/jpg");
     while ($row = mysql_fetch_array($gotten))
     {
        print $row['image'];
     }
     mysql_free_result($gotten);
  }
?>

最佳答案

尝试改变

<img width="550" src="getimage.php?ImageId=<?php echo mysql_result($res,$i,"ImageId"); ?       >  "/>


到这个:

<img width="550" src="getimage.php?ImageId=<?php echo mysql_result($res,$i,$_GET[ImageId]); ?       >  "/>

关于php - MYSQL,PHP从数据库中选择显示损坏的图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24585385/

10-12 07:22
查看更多