douji9518 2016-06-06 13:52
浏览 28

无法将图像加载到MYSQL表

As the title says, I can't insert & display any image to & from mySQL db table. Image table looks like the photo attached and my php code looks like this:

<?php
    $sql2 = "SELECT * FROM images";
    $records2 = mysql_query($sql2);
       while($images = mysql_fetch_assoc($records2)) {   
           echo $images['path'];     
       }
?>

The path is displayed in the page, not the actual image.

I've made the MYSQL connection so it is fine.enter image description here

  • 写回答

1条回答 默认 最新

  • doushao6874 2016-06-06 23:18
    关注

    This is an answer that I had prepared beforehand, but never submitted it at the time.

    Consult "Footnotes".

    You're just echoing the path here and not the image source.

    I.e.: <img src..>.

    You might have problems with this also, in the way you set that path for it, if and when you access your executable from a different location.

    echo "<img src=\"$images['path']\">";

    If that doesn't work, then that will mean that the path you've set for it, should have been as a full server path starting at the root, and not a relative path.

    If so, then you'll need to add to it.

    I.e.: echo "<img src=\"/var/usr/htdocs/Projects/facebook/img/$images['path']\">";

    or and as an example from the screenshot you left:

    echo "<img src=\"/Projects/facebook/img/$images['path']\">";


    Footnotes:

    "It works now @Fred-ii- the mySQL path wasn't quite accurate – Sergiu Turus 5 hours ago"

    It seems that I was right all along.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题