The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Different Image on Refresh, Image, Refresh, Cycle, Reload, Img, Src
DeDraconis
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.

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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post May 15 2018, 12:21 AM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,270
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
DeDraconis
post May 15 2018, 12:47 AM
Post #3





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



QUOTE(Darin McGrew @ May 15 2018, 01:21 AM) *

It sounds like your server isn't processing the PHP code at all. Is your server configured to process *.php files for PHP code?

I'm not sure, it's not my server. I asked the Webmistress first when it stopped working and she said she hadn't done any changes to how .php was run. Also, my computer hasn't changed in that time and that doesn't explain why it's not working locally either? I tried both Chrome and IE and they both do the same thing.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post May 15 2018, 07:39 AM
Post #4


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,917
Joined: 9-August 06
Member No.: 6



Do you run it through a server on your local computer? Otherwise it cannot work.

Try some other PHP to find out if PHP is working on your server. You could use phpinfo() which will get you a lot of information about the PHP configuration on your server - if it works.

Just put this in a document, name it something.php, upload it and go to it with your browser.

CODE
<?php
phpinfo();
?>

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
DeDraconis
post May 15 2018, 12:44 PM
Post #5





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



QUOTE(pandy @ May 15 2018, 08:39 AM) *

Do you run it through a server on your local computer? Otherwise it cannot work.

Try some other PHP to find out if PHP is working on your server. You could use phpinfo() which will get you a lot of information about the PHP configuration on your server - if it works.

Just put this in a document, name it something.php, upload it and go to it with your browser.

CODE
<?php
phpinfo();
?>


It also just shows up at plain text. 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? I opened it and it worked. It's the same, unedited set of files that are now behaving differently. Did they update it to need a local server to fix a security exploit or something?

Probably gonna get XAMPP so I can get the end result I want, but I'm really confused why I lost a feature that used to function just fine.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 15 2018, 02:19 PM
Post #6


.
********

Group: WDG Moderators
Posts: 7,818
Joined: 10-August 06
Member No.: 7



QUOTE(DeDraconis @ May 15 2018, 04:42 AM) *

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?

QUOTE(DeDraconis @ May 15 2018, 07:44 PM) *

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).





User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
DeDraconis
post May 15 2018, 03:28 PM
Post #7





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



QUOTE(Christian J @ May 15 2018, 03:19 PM) *

QUOTE(DeDraconis @ May 15 2018, 04:42 AM) *

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?

QUOTE(DeDraconis @ May 15 2018, 07:44 PM) *

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?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post May 15 2018, 08:19 PM
Post #8


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,917
Joined: 9-August 06
Member No.: 6



You must remember wrong. PHP doesn't run in the browser like JavaScript.

You tried the phpinfo() on your host's server, right? Not your own machine? Then PHP isn't working on the server.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
DeDraconis
post May 15 2018, 10:07 PM
Post #9





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



QUOTE(pandy @ May 15 2018, 09:19 PM) *

You must remember wrong. PHP doesn't run in the browser like JavaScript.

You tried the phpinfo() on your host's server, right? Not your own machine? Then PHP isn't working on the server.

I must. Though it really feels like I fell into some Mandela effect world.

Actually I tried on my own machine. This is what I got when I tried on the host's server.

QUOTE
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@website.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 Server at website.com Port 80
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 16 2018, 02:45 AM
Post #10


.
********

Group: WDG Moderators
Posts: 7,818
Joined: 10-August 06
Member No.: 7



QUOTE(DeDraconis @ May 16 2018, 05:07 AM) *

This is what I got when I tried on the host's server.

That shouldn't happen. Did you put something else in the file, or are you using some .htaccess directive that might be causing problems with PHP files? Otherwise my guess is that the server is misconfigured somehow, just like the message says. Ask the webhost support about it.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post May 16 2018, 12:00 PM
Post #11


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,917
Joined: 9-August 06
Member No.: 6



Yeah. And include a link to your php info. That should convince her.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

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: 25th May 2018 - 11:28 AM