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

  • SEARCH
  • Home
  • 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 9029177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:11:16+00:00 2026-06-16T07:11:16+00:00

I am trying to create a html page that uses a php page to

  • 0

I am trying to create a html page that uses a php page to decide what image to display at a set time.

The only problem is when i go to the php page it will display the correct image, but when i try to img src the php page, it gives a dead link on the HTML page. Here is the code I am using on the HTML and PHP page.

HTML:

<html>
<body>
<img src="http://itcacher85.hostzi.com/getImage.php" />
</body>
</html>

getImage.php:

<?php
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: January 01, 2013'); // Date in the past
header('Pragma: no-cache');

$h = date('Hi');

if ($h >= 2100 && $h < 2230){ $img = '40px-Dni5.png'; }
elseif ($h >= 2230 && $h < 0000){ $img = '40px-Dni3.png'; }

elseif ($h >= 0000 && $h < 0130){ $img = '40px-Dni7.png'; }
elseif ($$h >= 0130 && $h < 0137){ $img = '40px-Dni6.png'; }

elseif ($h >= 0137 && $h < 0138){ $img = '40px-Dnisolve.png'; }
elseif ($h >= 0138 && $h < 0300){ $img = '40px-Dni6.png'; }

elseif ($h >= 0300 && $h < 0430){ $img = '40px-Dni4.png'; }
elseif ($h >= 0430 && $h < 0600){ $img = '40px-Dni5.png'; }

else{ $img = 'where.png'; }
?>

<img src="<?php echo $img; ?>">

This code will display the image fine if you go to the PHP page, but when you link it as an image it does not work. I did a little research and found that I might need to add a header:

header('Content-type: image/png');

but when I add that in i get a dead link and no image is displayed on either the php page or the HTML page. Any help would be greatly appreciated.

  • 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-06-16T07:11:18+00:00Added an answer on June 16, 2026 at 7:11 am

    That’s not how images work. You need to output the image’s data, not another HTML fragment.

    <?php
    header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
    header('Expires: January 01, 2013'); // Date in the past
    header('Pragma: no-cache');
    header('Content-Type: image/png');
    
    $h = date('Hi');
    
    if ($h >= 2100 && $h < 2230){ $img = '40px-Dni5.png'; }
    elseif ($h >= 2230 && $h < 0000){ $img = '40px-Dni3.png'; }
    
    elseif ($h >= 0000 && $h < 0130){ $img = '40px-Dni7.png'; }
    elseif ($h >= 0130 && $h < 0137){ $img = '40px-Dni6.png'; }
    # HEY!  ^ LOOK OVER HERE! ... too many $ signs.
    
    elseif ($h >= 0137 && $h < 0138){ $img = '40px-Dnisolve.png'; }
    elseif ($h >= 0138 && $h < 0300){ $img = '40px-Dni6.png'; }
    
    elseif ($h >= 0300 && $h < 0430){ $img = '40px-Dni4.png'; }
    elseif ($h >= 0430 && $h < 0600){ $img = '40px-Dni5.png'; }
    
    else{ $img = 'where.png'; }
    
    readfile($img);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a page in ASP Classic that uses the jquery calendar.
I'm trying to create a HTML page that can be re sized to most
I'm trying to create a page that, when refreshed, will randomly load a url
SO basically im trying to create a button on a html webpage that uses
I am currently trying to create a multi-page form that uses both jQuery and
I am trying to create a PHP web page that requires reading some data
I am trying to create a custom accordion for my page to that display
I'm creating a web page that uses PHP and am trying to load an
I am trying to create a modular html document that employs smooth scrolling. If
I'm trying to create text in html, that once clicked, the the value of

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.