Page 1 of 1

get_random.phtml not working with IE 7--HELP!

Posted: Thu Apr 24, 2008 7:15 am
by eabigelow
Hi--

I am using the following PHP code to retrieve a random text entry from a msg.dat file, but the code does not seem to work in IE 7 (but does work in FireFox, Mozilla, and Safari). It will generate two entries at random, and then it will continue to show the second entry without randomly picking any more. The code is:

<?php

srand((double)microtime()*1000000);
$filename="msg.dat";
$message=file($filename);
$select=rand(0, count($message)+1);

$msg = "msg=$message[$select]";
echo "$msg";

?>

Does anyone have any idea of why this is happening, and even better, how to fix it? Many, many thanks for any help!!!!

Re: get_random.phtml not working with IE 7--HELP!

Posted: Thu Apr 24, 2008 8:19 am
by onion2k
I imagine IE7 is caching the page. Try sticking something like this at the top:

Code: Select all

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

Re: get_random.phtml not working with IE 7--HELP!

Posted: Thu Apr 24, 2008 8:37 am
by eabigelow
Hi--

Thanks very much for your quick reply--

Just to make sure (I am really new at this!). The beginning of the file should look like this?

<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

OR do I leave out the words "header"?

Again, many thanks!

Re: get_random.phtml not working with IE 7--HELP!

Posted: Thu Apr 24, 2008 10:27 am
by onion2k
You could always try both and see what happens.

Re: get_random.phtml not working with IE 7--HELP!

Posted: Thu Apr 24, 2008 10:33 am
by eabigelow
OK, thanks for all your help! I appreciate it!