Problem with Sleep command

by 7 replies
8
Hi all,

This test code runs through an array of email addresses with the goal of stopping every 20 rows for 60 seconds.

PHP Code:
    <?php
    $counter 
0;
    
$last 21;
    foreach (
$all_mails as $mails)
        {        
                 echo 
$mails['e_mail'],'br /';
                 
$counter ++;
                 if 
$counter $last
                 
{
                     
$counter 0;
                 
$last $last 20;
                 
sleep(60);
                 }
        }
    
?>
I get the error:

Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in C:\xampp\htdocs\mail_post.html_2.php on line 26

This is the '(' after the sleep command.

What's wrong please?

Mike
#programming #command #problem #sleep

  • to
    • [2] replies
    • Did the trick. Silly error. Thanks
    • Hi again,
      Now that the code's running it works until the first occurence of the sleep command and then gives this error.
      Fatal error:
      Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\mikesg_2\mail_system\mail\mail_pos t.html_2.php on line 30

      What now?

      Mike
  • Not a problem, it's a common error. Happens to the best of us.
  • Take a look at this page stackoverflow.com/questions/1176497/limit-execution-time-of-an-function-or-command-php If you have any more questions or anything, feel free to shoot me a pm or respond here and I'll help you get through it the best I can.
  • Thanks everyone for your contributions and help and thank you tgdrew for your suggestion, I'll certainly visit that site. Anyway, the problem has gone away as I don't need the pause anymore. Mike
  • Just in case anyone was reading this and wondered how to deal with that PHP error about max execution time... You can set the program to have an unlimited time limit by inserting this code at the top:

    Code:
    set_time_limit(0);

Next Topics on Trending Feed