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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.