Welcome to Gaia! ::


Howdy, I just made an image rotation script that should output a random image every time you refresh it. It works fine in IE, but in firefox it works for like the first 3 refreshes, and in Mozilla it only outputs the same image every single time.

I find that if you manually put the the url of the image into you're browser, it'll work every time, but if you have it in a page, and you press refresh it does what I have stated above..

Assuming this isn't a problem with my luck, is there anything I can do to get around this?

Here's the code:
<?
function ImageArray($directory) {

$handle = opendir($directory)

$imageArray = array()

/*Opens $handle*/
while (false !== ($file = readdir($handle))) {

if ($file != "." && $file != "..") {

/*If the file is .png then it goes into the array*/
if(ereg(".png$",$file)) {

array_push($imageArray, $directory."/".$file)

}

}

}

closedir($handle)

sort($imageArray)

return $imageArray;

}

$images = array()

$images = ImageArray("./sigs/wesk99")

shuffle($images)

Header("Location: ".$images[0])
?>



I've been looking at this for hours and I can't think of anything. Some new eyes might be able to find somthing I've overlooked. Any help would be greatly appreciated.

Thanks a lot smile

[FYI]That's the finished product in my signature.[/FYI]
Works for me, but then again I'm using IE6 SP1.

EDIT: Didn't work at all when tested under Firefox 1.0, not even the first three times.
Try using some or all of

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" wink ;
header("Last-Modified: " . gmdate("D, d M Y H:i:s" wink . " GMT" wink ;
header("Cache-Control: no-store, no-cache, must-revalidate" wink ;
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache" wink ;
I tried header("Cache-Control: no-store, no-cache, must-revalidate" wink ;

But I havnt tried the rest, thanks.

It seemed to work for like 5 refreshes then it went back to the same old same old. sweatdrop

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum