简体   繁体   English

网页不会显示图片

[英]Webpage won't display images

I've created a website and I'm using PHP to fetch an Oracle database table. 我已经创建了一个网站,并且正在使用PHP来获取Oracle数据库表。

I've coded the Oracle database table with the correct image file names and uploaded the pictures to a online directory but it's not showing up on the webpage. 我已经用正确的图像文件名对Oracle数据库表进行了编码,然后将图片上传到了在线目录,但是它没有显示在网页上。

This is my code fetching results from the database. 这是我的代码从数据库中获取结果。

<?php


while(oci_fetch_array($stmt)) {

echo("<tr valign=top bgcolor=#ccffcc>");

$fg1 = oci_result($stmt,"TITLE"); //"Title";
echo("<td width=100>");
echo ($fg1);
echo("</td>");
// Aspect value in column two
$fg2 = oci_result($stmt,"AUTHOR");//"Author";
echo("<td width=100>");
echo ($fg2);
echo("</td>");
$fg3 = oci_result($stmt,"PRICE");//"Price";
echo("<td width=75>");
echo ($fg3);
echo("</td>");
$fg4 = oci_result($stmt,"PHOTO");//"Photo";
echo ("<br><img src=http://xxxxxx.kz/home/preznek/public_html/website/search_pics".$fg4."><br>");
echo("</td>");

echo("</tr>");
} 
oci_close($connect); 
?>

What am I doing wrong? 我究竟做错了什么?

Two problems at a quick glance. 一目了然的两个问题。

  1. Your path is lacking quotation marks (single or double). 您的路径缺少引号(单引号或双引号)。 It should be like this: <img src="/path/to/image.jpg"/> 应该是这样的: <img src="/path/to/image.jpg"/>
  2. The path itself appears to be incorrect. 路径本身似乎不正确。 Typically if a directory is named "public_html", it is the root directory of your public-facing website. 通常,如果目录名为“ public_html”,则它是面向公众的网站的目录。 This means your path should be " http://xxxxxx.kz/website/search_pics/filename.jpg ". 这意味着您的路径应为“ http://xxxxxx.kz/website/search_pics/filename.jpg ”。

Try this please, 请尝试一下

change this, 改变这个

echo ("<br><img src=http://xxxxxx.kz/home/preznek/public_html/website/search_pics".$fg4."><br>");

to this, 为此,

echo "<br><img src='http://xxxxxx.kz/website/search_pics/".$fg4."'><br>";

You really don't need to use echo ("") you can just use it like this echo "" . 您真的不需要使用echo ("") ,只需像echo ""那样使用它。 I changed you code this might help you as well 我更改了您的代码,这也可能对您有所帮助

<table>
while(oci_fetch_array($stmt)) {
    //Variables
    $fg1 = oci_result($stmt,"TITLE"); //"Title";
    // Aspect value in column two
    $fg2 = oci_result($stmt,"AUTHOR");//"Author";
    $fg3 = oci_result($stmt,"PRICE");//"Price";
    $fg4 = oci_result($stmt,"PHOTO");//"Photo"; ?>

    <tr valign="top" bgcolor="#ccffcc">
    <td width="100">
    <?php echo $fg1;?>
    </td>;

    <td width="100">
    <?php echo $fg2;?>
    </td>

    <td width="75">
    <?php echo $fg3;?>
    </td>
    <td>
        <img src="http://xxxxxx.kz/website/search_pics/<?php echo $fg4?>">
    </td>
    </tr>

 <?php } ?>
</table>

Try this and let me know if it works or not. 试试这个,让我知道它是否有效。

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

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