Different Image on Refresh, Image, Refresh, Cycle, Reload, Img, Src |
Different Image on Refresh, Image, Refresh, Cycle, Reload, Img, Src |
DeDraconis |
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. CODE <?php header("Content-Type: image/jpeg"); $sigs = array(); $sigs[0] = "pic1.jpg"; $sigs[1] = "pic2.jpg"; $sigs[2] = "pic3.jpg"; $sigs[3] = "pic4.jpg"; mt_srand((double)microtime()*1000000); $sig = $sigs[mt_rand(0, count($sigs)-1)]; readfile($sig); ?> 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 |
Christian J |
May 15 2018, 02:19 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
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. (Just a sidenote: don't you need to use that old querystring trick on such URLs in order to prevent caching?) QUOTE It worked for me about.. four or five years ago? What has happened with the online site since then, did you remove it? I know for sure I am not running a local sever on my computer. I'm just really confused why ~2 years ago I didn't need to? ... Did they update it to need a local server to fix a security exploit or something? No, pandy meant that in order to run PHP offline on your own computer, you also need a local server (such as XAMPP). A site at your web host is run from their online server, which should support PHP (especially if they say so). |
DeDraconis |
May 15 2018, 03:28 PM
Post
#3
|
Group: Members Posts: 5 Joined: 14-May 18 Member No.: 26,645 |
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. (Just a sidenote: don't you need to use that old querystring trick on such URLs in order to prevent caching?) QUOTE It worked for me about.. four or five years ago? What has happened with the online site since then, did you remove it? I know for sure I am not running a local sever on my computer. I'm just really confused why ~2 years ago I didn't need to? ... Did they update it to need a local server to fix a security exploit or something? No, pandy meant that in order to run PHP offline on your own computer, you also need a local server (such as XAMPP). A site at your web host is run from their online server, which should support PHP (especially if they say so). I misspoke on my last message, it was ~4-5 years ago like I said at first. ~2years ago I hadn't been messing with it. What I'm saying is, the same file, on the same computer, used to work offline just fine without me having to load it onto the site I was using. And I wasn't running any .php software/localhost. The only thing I can think of that might have changed is how my browser reads it, cause I do keep Chrome up to date (and I assume IE updates itself when I'm not looking). At this point I'm not confused about how to get it to work, I'm just wondering what changed that makes it so I need to, and why? |
Lo-Fi Version | Time is now: 28th April 2024 - 05:39 AM |