The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Different Image on Refresh, Image, Refresh, Cycle, Reload, Img, Src
post May 14 2018, 09:42 PM
Post #1

Group: Members
Posts: 5
Joined: 14-May 18
Member No.: 26,645

Hi, I hope this is in the right spot. Wasn't sure if it should be here or on the php board but here felt like it made more sense.

I used to have a working method so that I could put in <img src=rotate.php>, and that .php file had a list of four image addresses in it. Whenever someone loaded the page, it would select a random one and it would go. It worked for me about.. four or five years ago? It would work both when I went to rotate.php directly, or when I was looking at a page that had it as an image source.


header("Content-Type: image/jpeg");  

$sigs = array();  

$sigs[0] = "pic1.jpg";  

$sigs[1] = "pic2.jpg";  

$sigs[2] = "pic3.jpg";  

$sigs[3] = "pic4.jpg";  


$sig = $sigs[mt_rand(0, count($sigs)-1)];  



Now though, it doesn't work. If I go to rotate.php in Chrome it is showing the above code rather than running the function, and if I go to a page that has it as an image source it just shows a broken image. I'm like, really confused why it just stopped working. It's not working at the place I had it uploaded, and it's not working locally just on my computer either.

So I know this seems like a .php issue and maybe it is, but posting it here in HTML cause what I need is <img src=something> to rotate through a list, and don't particularly care if it's via a php file or something else.

Any advice on how to do this would be much appreciated. I tried Googling it and I think the terms I was looking for (everything I put as the Topic Description) have too many uses, and I don't even know what language I really want to find the answer in.

Thank you
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Reply to this topicStart new topic
Darin McGrew
post May 15 2018, 12:21 AM
Post #2

WDG Member

Group: Root Admin
Posts: 8,289
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3

It sounds like your server isn't processing the PHP code at all. Is your server configured to process *.php files for PHP code?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


- Lo-Fi Version Time is now: 18th February 2019 - 09:57 PM