while using sleep you may also need to adjust the 30 second run time limit so that it isn't exceeded while sleeping
set_time_limit(number of seconds to limit the runtime of the current file to);
Main Topics
Browse All TopicsI have a page in PHP that accesses an XMLRPC Server. However, sometimes it does not display the response from the server, and sometimes it does...but it ALWAYS ALWAYS reaches the server because I see the data pass on the other end. And the data is passed TWICE for some reason too!!
How can I make the page wait for a few seconds, then proceed? Is there a comman in PHP to make the page wait or a timer?
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I'm not sure how you have implemented the model but an easy way is to just poll the call, check if it's returning any output and keep looping(or sleeping with sleep()) till it does. To prevent your script from timing out make sure you send some data to the browser and then flush it. The basic code would be:
echo "Waiting for response from server .... <br />";
flush();
Remmeber to flush so that the data is sent forcibly to the browser.
alternatively, if you are launching the query from a web page you could use a JavaScript wait and loop: thus, you would not have the problem of maximum run times for php scripts
<?php
...
$wait_delay= 10000; //milliseconds... some tuning neeeded!
$comd="<script language='JavaScript' type='text/javascript'>win
$comd .= '"' .$_SERVER['PHP_SELF'].'"'.
$comd .= "<noscript>\n";
echo $comd;
...
Business Accounts
Answer for Membership
by: ZylochPosted on 2006-03-05 at 16:09:18ID: 16110223
Hi JuniorBee,
You can try:
sleep(NUMBER_OF_SECONDS);
or
usleep(NUMBER_OF_MS);
Regards,
Ted