网页将不会显示图像

问题描述:

我创建了一个网站,我正在使用PHP来获取Oracle数据库表。网页将不会显示图像

我已经用正确的图像文件名对Oracle数据库表进行了编码,并将图片上传到了一个在线目录,但没有显示在网页上。

这是我的代码从数据库中获取结果。

<?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); 
?> 

我在做什么错了?

+0

这张图片确实存在'search_pics“。$ fg4。”'? –

+0

不,它是包含所有图片的文件夹。图片名称picture1.png等 – c0nfus3d

+0

那么它需要是'search_pics /".$ fg4' –

试试这个请,

改变这一状况,

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

此,

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

你真的不需要使用echo ("")你可以使用它像这样echo ""。 我改变你的代码,这可能帮助你以及

<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> 

试试这个,让我知道,如果工程或没有。

+0

您的代码存在问题。照片可以正确加载,但是它们在桌子上方和外面。不知道如何解决它。 – c0nfus3d

+0

它缺少打开'​​'标签它现在应该工作。 – Sand

+0

照片仍在桌子外:/他们坐在桌子顶部 – c0nfus3d

快速浏览两个问题。

  1. 您的路径缺少引号(单或双)。它应该是这样的:<img src="/path/to/image.jpg"/>
  2. 路径本身似乎是不正确的。通常,如果某个目录的名称为“public_html”,则它是您的公众网站的根目录目录。这意味着你的路径应该是“http://xxxxxx.kz/website/search_pics/filename.jpg”。