脚本在生产服务器上运行时,图像不显示

时间:2011-06-21 07:42:45

标签: php

我有这个脚本在我的XAMPP本地主机上没有问题:

<html>
<head>
<title>Gallery</title>
<style type="text/css">
body {
    margin: 0 auto;
    padding: 0;
    width: 500px;
    color: #000000;
    position: relative;
}
.gallery {
    list-style: none;
    margin: 0;
    padding: 0;
}
.gallery li {
    margin: 10px;
    padding: 0;
    float: left;
    width: 120px;
    height: 100px;
}
.gallery img {
    background: #fff;
    border: solid 1px #ccc;
    padding: 4px;
    width: 110;
    height: 90;
}
.gallery a:hover img
{border: 1px solid #0000ff;
position: absolute;
top: 0; left: 0;
width:400;
height:300;
}
</style>
</head>

<body>
<ul class="gallery">
   <?php
//header("Content-type: image/jpg;\n");

  $db_connect = mysql_connect('localhost', 'Beta_tester', 'alfa1gama2');
        if(!$db_connect)
                {
                         die('Не може да се осъществи връзка с базата данни' . mysql_error());
                }
  mysql_select_db("Beta_tester", $db_connect);
  $rs = mysql_query('SELECT * FROM gallery WHERE oferta_id=2');


 while($row = mysql_fetch_array($rs))
  {
        echo '<li><a target="_blank" href="http://mysite/fimage.php?id='.$row['id'].'"><img src='.$row['location'].' alt="image"/></a></li>';
  }

?>
</ul>
</body>
</html>

在我的本地服务器上没关系,但是当我在生产服务器上传它时,我得到了这个输出:

PIC1: enter image description here

它没有显示得很好,但这只是一个带有图像损坏图像的空白块。头部(内容)被评论 - 我后来添加它因为我看到类似的问题解决了这个,但也许我正在使用它错了或者它可能是别的。

由于

Leron

4 个答案:

答案 0 :(得分:1)

确保图像(URL)的位置是有效的。尝试打印图片网址并尝试在另一个标签页中打开,以确保它是有效的网址。

另外,在图像src属性上传递双引号,如:

<img src="'.$row['location'].'" alt="image" />

答案 1 :(得分:0)

我想问题出在这里:

<img src='.$row['location'].' alt="image"/>

请告诉我们$row['location']

的价值

答案 2 :(得分:0)

您的浏览器必须具有查看源功能。在那里你可以看到脚本的整个输出。如果出现问题你应该在那里看到它。

答案 3 :(得分:0)

通过firebug检查图像src的值,并查看源代码。通过这种方式,您可以确定您的路径是否正确。