PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 30th, 2003, 01:03 PM
[=hris [=hris is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 [=hris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
caching problem (i think) in php

Hi,

I am trying to get php to randomise a value, however it always picks the same number. Sometimes if i change the address bar to be something along the lines of index.php?etgneuj it sometimes works, but even then, only two numbers come up of a rand between 0 and 200.

I have tried

<?
header ("Expires: ".gmdate("D, d M Y H:i:s", time())." GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
?>

but it still doesnt work

i am using the code $var = rand(0,200);

Anyone have any ideas ?

Reply With Quote
  #2  
Old December 30th, 2003, 02:31 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
The following code works like a charm for me with no special header stuff. Is it possible you're using $var elsewhere, perhaps as a session or get/post variable with register_globals turned on?

PHP Code:
<?php
                                                                                                                                                  
$x
=rand(0,200);
print 
$x;
                                                                                                                                                  
?>

Reply With Quote
  #3  
Old December 30th, 2003, 02:40 PM
[=hris [=hris is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 [=hris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am not using post / get anywhere, and i am certain that randomNum isnt being over-written

One thing i have just noticed is if the browser has been totally closed (no windows) then re-opened, it generates a number, hit refresh, it generates another number, hit refresh again it goes back to the first number, and however many times you press refresh it will not budge from that number

Any other ideas?

Reply With Quote
  #4  
Old December 30th, 2003, 03:18 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I guess check your PHP options and see if there's some kind of caching going on.

Reply With Quote
  #5  
Old December 30th, 2003, 04:02 PM
[=hris [=hris is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 [=hris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well that is odd ... it must have been a caching problem on the server ... i put it onto my web server, and it works fine now. Thanks for the help!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > caching problem (i think) in php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT