Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MYSQL、PHP从数据库中选择显示损坏的图像_Php_Mysql_Select_Blob - Fatal编程技术网

MYSQL、PHP从数据库中选择显示损坏的图像

MYSQL、PHP从数据库中选择显示损坏的图像,php,mysql,select,blob,Php,Mysql,Select,Blob,我已经试了几个小时了,但还是不走运。一旦图像被插入到数据库中,但当我从数据库中选择时,所有图像都被破坏。我使用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){ ?

我已经试了几个小时了,但还是不走运。一旦图像被插入到数据库中,但当我从数据库中选择时,所有图像都被破坏。我使用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++;
}
?>
尝试改变

<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]); ?       >  "/>

如果要在一页中显示所有图像。您不需要从url获取ImageId。直接从数据库中获取。就这样,

$gotten = mysql_query("SELECT  'Image' FROM  'animals' LIMIT 0 , 30");
while ($row = mysql_fetch_array($gotten)){
  print "<img src=\"../images/$row['image']\" />;
}

让我看看数据库是什么样子。创建表示例ImageId int NOT NULL AUTO_INCREMENT,Name varchar30 NOT NULL,Image LONGBLOB,PRIMARY keymageID;似乎您不需要$u GET['ImageId']。您可以从url获取该值,但对数据库不做任何操作。你打算在这里干什么?您是要根据$\u get['ImageId']的值获取图像,还是只是从mysql循环调用图像?我正在尝试在一个页面中显示数据库中的每个图像。您是否在查看所有图像的php文件中正确获取图像url?
$gotten = mysql_query("SELECT  'Image' FROM  'animals' LIMIT 0 , 30");
while ($row = mysql_fetch_array($gotten)){
  print "<img src=\"../images/$row['image']\" />;
}