【问题标题】:Why is the image not displaying为什么图片不显示
【发布时间】:2017-06-06 17:46:34
【问题描述】:

我的 webserver 和 sql server 工作正常,但是当我运行文件时,没有显示图像,并且出现像 �})>�}(���>��j|��0�Ry>�s 这样的字符而是。我错过了什么?下面的 cobe 是页面的一部分。

    <body>
         <?php
    $servername = "localhost";
    $user = "root";
    $passw = "Ajax3617";
    $dbname="sailingdb";
    // Create connection
    $conn = new mysqli($servername, $user, $passw, $dbname);

    $sql = "SELECT picturefile FROM pictures";
    $result = mysqli_query($conn,$sql);
    while ($row = mysqli_fetch_assoc($result))  {

echo '<img src="'.$row['picturefile'].'" width="175" height="200" />';

    } ?>
</body>
</html>

【问题讨论】:

  • 检查 $row['picturefile'] 中返回的内容:var_dump($row['picturefile']);
  • 应用 css 后屏幕上的此文本 "; var_dump($row['picturefile']); } ?>
  • “当我运行文件时,没有显示图像,而是出现了字符 } ?&gt; - 听起来好像 php 没有被解析。
  • 您还为查询使用了错误的连接变量,应该是连接而不是数据库,因此您的代码由于某些原因而失败。
  • 引用错误&lt;img src="'.$row['picturefile']."'

标签: php html image


【解决方案1】:
echo "<img src="'.$row['picturefile']."' >"; 

应该替换为

echo '<img src="'.$row['picturefile'].'" >';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-06
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 2019-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多