Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:24:35+00:00 2026-05-27T06:24:35+00:00

I have an ul with a li that cannot find a .PNG image associated

  • 0

I have an ul with a li that cannot find a .PNG image associated with the list item ‘li’ in the code here:

$pngFilename= 'C:/xampp/htdocs/myProj/' . 'just_a.png';
echo 'pngFilename is "', $pngFilename, '" -- that was the .png image filename.';


// within a 'ul' is this li item that displays an image (the ul code is simplified 
// to only show the item that (needs to but doesn't!) display a .PNG image.)
echo '<ul>';
echo '<li>';
echo '<a href="http://localhost/myProj/just_an.htm">';
echo '<img src="', $pngFilename, '"';            
echo 'alt="http://localhost/myProj/the_other.png"';

// NOTE -- I left out the close /> to the img statement when I copied my code here but 
// it was in fact in my source code.
echo '/>'; 

echo '</a>';
echo '</li>';
echo '</ul>';

Before I wrote the above php code, I tested just the raw html and it was fine — my .PNG file called
C:/xampp/htdocs/myProj/just_a.png was displayed correctly.

But when I switched to php server-side generation of the html, the C:/xampp/htdocs/myProj/just_a.png image does not appear, only the ‘cant find it’ default small image appears that looks like a piece of paper torn horizontally.

Any ideas? The .png file exists and so does the directory and the html correctly displayed the image, but when I put the html into php ‘echo’ calls I must be screwing something up, just not sure what.

To make sure I have the correct path and filename you’ll see I echo it out at the top of the code.
The php variable $pngFilename is displayed when I do ‘View Source’ in the browser as:

pngFilename is "C:/xampp/htdocs/myProj/just_a.png"  -- that was the .png image filename.

The only other thing to mention is that the ‘alt’ link, the ‘alt=”http://localhost/myProj/the_other.png”&#8216; — this link (not the image) shows as blue underlined link text.

Why did this work in my html but breaks when I use the ‘echo’ in php? After all, the ‘echo’ simply sends the html to the client side — and that .png file is 100% definitely there and displays fine when I run the above html outside of php’s “echo” command.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:24:35+00:00Added an answer on May 27, 2026 at 6:24 am

    This is because the path to the image changes depending on how your viewing the page. in a local context or from a server context; and since you are using an absolute path instead of a Relative path the system can’t adjust for the change in the location of the image. Unlike when using a PHP function that calls on the php file system functions that do use the internal file system. what your doing is having it send a text file to the browser which isn’t rendered as HTML code until after PHP has finished. because of that it has no access to the php file system to resolve the path to the image on the server. the way to fix it would be to use the path to the image Relative to the PHP script or use the web accessible path to the image

    $pngFilename= 'C:/xampp/htdocs/myProj/' . 'just_a.png';
    

    Should for example be

    $pngFilename= 'http://localhost/myProj/' . 'just_a.png';
    

    or if the image and the php file are in the same directory you could just do

    $pngFilename= 'just_a.png';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few things that I cannot find a good way to perform
I have a relatively simple question that I cannot seem to find the answer
Put it another way: what code have you written that cannot fail. I'm interested
I really cannot find the solution on other questions! I have that accordion menu
I've been looking, but I cannot find an image file to CSV converter that
In SQL its possible to have fields that cannot contain duplicate data. How is
In one of my projects, I have some classes that represent entities that cannot
I have the below markup that cannot be changed: <div>Some data</div> <span>More data</span> <a>Link
I have just heard that the iphone cannot do double natively thereby making them
I have a simple problem that i cannot solve. I have a dictionary: aa

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.