Jump to content

Image wont display


runnerpaul

Recommended Posts

Hi,

 

Im trying to get an image to display from a reference in the database but am having no joy. At the minute Im just playing about with PHP to get familiar with it so you can ignore most of the code. The line im interested in is:

 

<td><?php echo "<img src=\"C:\wamp\www\fermpix\Pics\'{$row["Name"]}'\">";?></td>

 

When I view the page in my browser I see the attached. Can anybody see what im doing wrong?

 

Heres the full page:

 

<!DOCTYPE HTML PUBLIC 
  "-//W3C//DTD HTML 4.0 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <title>Browse Upload Files</title>
</head>
<body bgcolor="white">

<?php
  error_reporting(E_ALL);  
  include 'db.inc';
  
  $query = "SELECT ID, Name, Path, Date, Description FROM Pics";

  if (!($connection = @ mysql_pconnect($hostName, 
                                    $username,
                                    $password)))
     showerror();

  if (!mysql_select_db("fermpics", $connection))
     showerror();
        
  if (!($result = @ mysql_query ($query, $connection)))
     showerror();
?>
    <h1>Image database</h1> 

    <h3>Click <a href="insert.php">here</a> to 
upload an image.</h3>
<?php 
  //require 'disclaimer';

  if ($row = @ mysql_fetch_array($result))
  {
?>

    <table>
    <col span="1" align="right">
    <tr>
       <th>File Name</th>
       <th>Date</th>
       <th>Image</th>

    </tr>
<?php
   do 
   {
?>
    <tr>
       <td><?php echo "{$row["Name"]}";?></td>         
       <td><?php echo "{$row["Date"]}";?></td>
       <td><?php echo "<img src=\"C:\wamp\www\fermpix\Pics\'{$row["Name"]}'\">";?></td>
    </tr>
<?php
   } while ($row = @ mysql_fetch_array($result));
?>
    </table>
<?php
  } // if mysql_fetch_array()
  else
     echo "<h3>There are no images to display</h3>\n";
?>
</body>
</html>

 

I would appreciate any help.

 

Cheers

Paul

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/220876-image-wont-display/
Share on other sites

Hi,

the easiest way is to use a relative link.

instead of write this: <?php echo "<img src=\"C:\wamp\www\fermpix\Pics\'{$row["Name"]}'\">";?>

-----------------------------------------------

Write this:

<?php echo "<img src=\"/fermpix/Pics/{$row["Name"]}\" />";?>  if your DOCUMENT_ROOT is "C:\wamp\www"

<?php echo "<img src=\"/Pics/{$row["Name"]}\" />";?>  if your DOCUMENT_ROOT is "C:\wamp\www\fermpix"  or  simply

<?php echo "<img src=\"Pics/{$row["Name"]}\" />";?> if your Pics is your image folder and it is located in the same level as your PHP file.

Link to comment
https://forums.phpfreaks.com/topic/220876-image-wont-display/#findComment-1143780
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.