ds08541 2014-05-29 01:38
浏览 49

图像不在PHP中显示

Here don't know why image is not being displayed in php, I think this line has some problem.

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

the full code is like this

<?php 
$result = mysqli_query($con, "SELECT name, email, branch, batch, position, pic FROM users ");
while ($row = mysqli_fetch_array($result)) {
   echo '<section>'
      . '<header>'
      . '<h2>' . $row['name'] . '</h2>'
      . '<p><span class="posted">'
      . '<br>'
      . $row['batch']
      . '<br>'
      . $row['branch']
      . '<br>'
      . $row['email']
      . '<br>'
      . 'Profession:'
      . $row['position']
      . '</header>'
      . '</section>'
      . '</div>'
      ;
} 
echo '<img src="' . $row['pic'] . '">';
?>
  • 写回答

1条回答 默认 最新

  • douna2917 2014-05-29 01:47
    关注

    Your while(){} loop will run while mysqli_fetch_array() returns arrays with information.

    In the last iteration, mysqli_fetch_array() will return NULL and the loop will stop.

    At this point $row['pic'] is not set. In fact $row is no longer an array at all. $row is NULL.

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料