【问题标题】:Storing image path in a variable将图像路径存储在变量中
【发布时间】:2012-08-06 22:36:31
【问题描述】:

我有一个存储用户图像路径的数据库,例如 images/profile/950baasfaa88c.jpg。现在,当我尝试将它放入一个变量并用图像标签包围它时,只会出现一个空白图像而不是图像本身......

    $profile_picture = $row['profile_image'];

<img src="'.$profile_picture.'" width=50 height=50 />

【问题讨论】:

  • 渲染页面上的“查看源代码”是什么样的? (来自浏览器)
  • 您确定相应的图像放置在正确的位置吗?当找不到 标签所指的图像时,浏览器会显示空白图像。
  • 在提出此类问题时尽量提供更多细节。
  • 你能把服务器返回的内容通过页面源发布出来

标签: php database image variables profile


【解决方案1】:

你还没有回显 PHP

<img src="'.$profile_picture.'" width=50 height=50 />

应该是

<img src="<?= $profile_picture ?>" width=50 height=50 />

【讨论】:

    【解决方案2】:

    你需要回显值

    <img src="<?php echo $row['profile_image']; ?>" width=50 height=50 />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多