简体   繁体   English

来自数据库的图像路径未显示-PHP

[英]Image path from database not displaying-PHP

Creating a shop page and I'm trying to get the image for the item to display.So In my products database i have products_image that has a path set directly to the image. 创建一个商店页面,然后尝试获取要显示的商品的图像。因此,在我的商品数据库中,我有products_image,该商品的路径直接设置为该图片。 but it won't display. 但不会显示。 is there something wrong with my php? 我的php有什么问题吗?

         while ($row = mysql_fetch_array($results)) {
      extract($row);
      echo "<tr><td>";
      echo "<a href=\"getprod.php?prodid=" . $products_prodnum . "\">";
      echo "<em><img src=\" . $products_image . \"></em></a></td>";
       echo "<td>";
       echo "<a href=\"getprod.php?prodid=" . $products_prodnum . "\">";
       echo $products_name;
       echo "</td></a>";
       echo "<td align=\"right\">";
       echo "<a href=\"getprod.php?prodid=" . $products_prodnum . "\">";
       echo "$" . $products_price;
       echo "</a></td><td><a href=\"getprod.php?prodid=" . $products_prodnum . "\">Buy                now!</a></td></tr>";
        }
        ?>

Try changing echo "<em><img src=\\" . $products_image . \\"></em></a></td>"; 尝试更改echo "<em><img src=\\" . $products_image . \\"></em></a></td>"; echo "<em><img src=\\" . $products_image . \\"></em></a></td>"; to the following: 到以下内容:

echo "<em><img src=\\"" . $products_image . "\\"></em></a></td>";

It appears that you are missing a pair of quotations. 看来您缺少一对引号。

Check your upload path. 检查您的上传路径。 Also your variable is not coded correctly as you can see it is brown. 此外,您的变量是不正确编码为你可以看到它是棕色的。 try the answer above, should work, if not then your path is wrong. 尝试上面的答案,应该可以,如果没有,那么您的路径是错误的。 If located at root of directory check file is uploaded first and then check why it is not displaying. 如果位于目录检查文件的根先上传,然后检查它为什么不显示。

for example 例如

public function image_path() 
{  
  return $this->upload_dir.DS.$this->filename;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM