Images isn't showing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fahim
Forum Commoner
Posts: 36
Joined: Sun Jan 05, 2014 7:06 pm
Location: Dhaka, Bangladesh

Images isn't showing

Post by fahim »

Hi,

I'm quite new to PHP. As a part of my learning process, I'm trying to show a list of images in a page, but unfortunately the images aren't showing !!! :banghead:

I've saved my variables in a seperate file, in there I've saved the upload path, like below :

Code: Select all

define('MM_UPLOADPATH', 'images/');
After that, I've wrote the code and used that upload path by "require_once". The code is here :

Code: Select all

while ($row = mysqli_fetch_array($data)) {
    if (is_file(MM_UPLOADPATH . $row['picture']) && filesize(MM_UPLOADPATH . $row['picture']) > 0) {
      echo '<tr><td><img src="' . MM_UPLOADPATH . $row['picture'] . '" alt="' . $row['first_name'] . '" /></td>';
    }
    else {
      echo '<tr><td><img src="' . MM_UPLOADPATH . 'nopic.jpg' . '" alt="' . $row['first_name'] . '" /></td>';
    }
    echo '<td>' . $row['first_name'] . '</td></tr>';
  }
After this I've put the images in the "images" folder, located in the same folder with the "index.php".

It seems everything is okay to me, but unfortunately the images are missing when I'm accessing the page via a browser (please check the attached screenshot)

I'd be really grateful if anyone could help me to solve this issue.

Thanks in advance.
Attachments
images missing.png
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Images isn't showing

Post by Celauran »

Have you checked the image path in the rendered source?
fahim
Forum Commoner
Posts: 36
Joined: Sun Jan 05, 2014 7:06 pm
Location: Dhaka, Bangladesh

Re: Images isn't showing

Post by fahim »

Really thanks for your reply, but it's not clear to me that, what you are trying to mean by "rendered source"? Would you please clarify it?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Images isn't showing

Post by Celauran »

Load the page in your browser, view source, check the image path.
fahim
Forum Commoner
Posts: 36
Joined: Sun Jan 05, 2014 7:06 pm
Location: Dhaka, Bangladesh

Re: Images isn't showing

Post by fahim »

Thanks for the clarification. In the browser, when I'm viewing the source, I'm getting any image path (maybe because I'm using "require_once" and saved that path in a different file). Whatever the source is here. Believe that you'll understand the problem from this :

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Mismatch - Where opposites attract!</title>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
  <h3>Mismatch - Where opposites attract!</h3>

&#10084; <a href="viewprofile.php">View Profile</a><br />&#10084; <a href="editprofile.php">Edit Profile</a><br /><h4>Latest members:</h4><table></table>
</body> 
</html>
Thanks in advance.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Images isn't showing

Post by Christopher »

There are no images -- so either there is some error in the MySQL connection or query, or there are no rows returned by the query.
(#10850)
fahim
Forum Commoner
Posts: 36
Joined: Sun Jan 05, 2014 7:06 pm
Location: Dhaka, Bangladesh

Re: Images isn't showing

Post by fahim »

Thanks everyone for your help. My problem is solved. Marking this post as SOLVED.
Post Reply