Web Hosting Talk


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : PHP sleep() problem
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.

 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-27-2008, 06:43 PM
cybercast cybercast is offline
View Beta Profile
WHT Addict
 
Join Date: Apr 2007
Location: Panama
Posts: 145
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

Reply With Quote
Sponsored Links
  #2  
Old 11-27-2008, 06:51 PM
etogre etogre is offline
View Beta Profile
Web Hosting Evangelist
 
Join Date: Aug 2003
Location: California, USA
Posts: 532
sleep(30); ?





__________________

Reply With Quote
  #3  
Old 11-27-2008, 07:09 PM
cybercast cybercast is offline
View Beta Profile
WHT Addict
 
Join Date: Apr 2007
Location: Panama
Posts: 145
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

Reply With Quote
Sponsored Links
  #4  
Old 11-27-2008, 08:53 PM
azizny azizny is offline
View Beta Profile
Web Hosting Master
 
Join Date: Mar 2004
Location: USA
Posts: 4,342
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.

Reply With Quote
  #5  
Old 11-27-2008, 11:36 PM
cybercast cybercast is offline
View Beta Profile
WHT Addict
 
Join Date: Apr 2007
Location: Panama
Posts: 145
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

Reply With Quote
  #6  
Old 11-28-2008, 12:19 AM
foobic foobic is offline
View Beta Profile
Community Liaison
 
Join Date: Feb 2005
Location: Australia
Posts: 3,430
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

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement: