Web Hosting Talk







View Full Version : PHP sleep() problem


cybercast
11-27-2008, 06:43 PM
PHP sleep() problem

Hello,
I have a script that is running a loop that waits 30 seconds to execute each time.
$time=30;
while (){
run a mysql update
echo "ok";
}
in my browser i got the ok every 30 secs.. that is fine. The problem is that the mysql update is done all at the same time.
Is there a way to make the mysql update wait the 30 secs????
I have being using flush(); sleep; and I get the same result.
Any help will be greatly appreciated.
Cheers from sunny (not to sunny today) Panama.





__________________
Cyber Cast Intlhttp://www.offshore-web-hosts.comOffshore Hosting, Offshore Dedicated Servers and Offshore VPS based in Panama

etogre
11-27-2008, 06:51 PM
sleep(30); ?





__________________

cybercast
11-27-2008, 07:09 PM
sorry I forgot to post it and it is present at my script. The script waits.. but the mysql update run the loop without waiting.
$time=30;
while (){
run a mysql update
echo "ok";
sleep(30);
}





__________________
Cyber Cast Intlhttp://www.offshore-web-hosts.comOffshore Hosting, Offshore Dedicated Servers and Offshore VPS based in Panama

azizny
11-27-2008, 08:53 PM
First query will run right away, then wait 30s before all other queries.
Peace,





__________________NEW: What Is Their IP - Anyone's IP a click away.
URL Tracker, Shortener, Blocker, Unblocker, Whois and More.

cybercast
11-27-2008, 11:36 PM
that should happen but is not happening.
That is the problem but at the browser I get the ok every 30 secs





__________________
Cyber Cast Intlhttp://www.offshore-web-hosts.comOffshore Hosting, Offshore Dedicated Servers and Offshore VPS based in Panama

foobic
11-28-2008, 12:19 AM
If the browser waits the 30 seconds then the script is behaving as you want it to.
So the real problem is most likely either in your update query or in your method of detecting the update. Post some information on those and perhaps we'll see the problem.





__________________
Chris <ClonePanel>
"Not everything that can be counted counts, and not everything that counts can be counted" - Albert Einstein