...

View Full Version : IE Problem



Rapport
07-15-2008, 06:56 AM
Hi,

My friend helped me create a PHP script that randomizes picture upon refresh, but it doesn't work in Internet Explorer. How do you solve this?

PHP (rewritten as a rotate.jpg)
<?php
$images=Array(
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture01.jpg",
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture02.jpg",
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture03.jpg",
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture04.jpg",
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture05.jpg",
);
shuffle($images);
//header("Location: ".$images[0]);
echo file_get_contents ($images[0]);
?>

.htaccess
<FilesMatch rotate.jpg>
ForceType application/x-httpd-php
</FilesMatch>


Image: http://rappating.ismyse.com/rotate/rotate.jpg
(Webpage, http://rappating.ismyse.com/rotate/)

_Aerospace_Eng_
07-15-2008, 09:04 AM
Append a random number to the url of the image.

<?php
$images=Array(
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture01.jpg?id=".rand(0,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture02.jpg?id=".rand(0,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture03.jpg?id=".rand(0,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture04.jpg?id=".rand(0,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture05.jpg?id=".rand(0,1000)
);
shuffle($images);
//header("Location: ".$images[0]);
echo file_get_contents ($images[0]);
?>

Rapport
07-16-2008, 12:17 AM
I relabeled first 0's in .rand(0,1000) to 1, 2, 3, 4, 5 respectively, but the image still doesn't show up on IE7.


Does it work on yours?
(Recheck webpage)

rafiki
07-16-2008, 12:20 AM
Try adding cache control to make the page load from the site everytime instead of loading from the temp dir....

Fou-Lu
07-16-2008, 12:23 AM
I find that I often need both the cache control (for IE) and the random numbers (FF) for displaying images. I don't know why the FF caches it but it definitely does. Took me awhile waaaayy back to realize a t=rand() does the trick :)

Rapport
07-16-2008, 04:13 AM
Fou-Lu, could you explain to me how to do that?

Fou-Lu
07-16-2008, 05:18 AM
Mmkay, the PHP headers need to be like so:


header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

You could also use a pragma for it, but the two above should be sufficient. Those are taken directly from the PHP site's header section. Since these are headers you must place them before any output to the page (echo, print, and no spaces or output before <?php). As for the image, just use what Aerospace posted, that should provide a unique image so that any attempted cache will still require looking up the image to use. The queystring part is ignored by the image so you don't need to worry about anything bad happening. Thats the best part about the browser - its easily fooled :D

Rapport
07-16-2008, 04:31 PM
I feel like I'm doing something wrong...

PHP
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$images=Array(
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture01.jpg?id=".rand(1,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture02.jpg?id=".rand(2,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture03.jpg?id=".rand(3,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture04.jpg?id=".rand(4,1000),
"http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture05.jpg?id=".rand(5,1000)
);
shuffle($images);
//header("Location: ".$images[0]);
echo file_get_contents ($images[0]);
?>

Is this ok?

---

EDIT

I tested the webpage on IE on another computer, and it appears that your script works.
My IE is probably still running on a temporary cache, which is why the webpage looks like it has a broken image.

But that's ok. Thank you _Aerospace_Eng_, Fou-Lu.

CFMaBiSmAd
07-16-2008, 04:44 PM
Both the links you posted currently work in IE7. There appear to be about 6 different images.

What exact symptoms do you get?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum