Problem with Sleep command

7 replies
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
#command #problem #sleep
  • Profile picture of the author tgdrew
    change

    if $counter = $last
    to
    if
    ($counter == $last)


    Other than that, I don't see any errors, although it is early yet.



    {{ DiscussionBoard.errors[4117351].message }}
    • Profile picture of the author MikeHayes
      Did the trick. Silly error. Thanks
      Signature

      * * * * My site * * * *
      * * * * My paintings * * * *

      {{ DiscussionBoard.errors[4117517].message }}
    • Profile picture of the author MikeHayes
      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
      Signature

      * * * * My site * * * *
      * * * * My paintings * * * *

      {{ DiscussionBoard.errors[4118188].message }}
  • Profile picture of the author tgdrew
    Not a problem, it's a common error. Happens to the best of us.
    {{ DiscussionBoard.errors[4117639].message }}
  • Profile picture of the author tgdrew
    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.
    {{ DiscussionBoard.errors[4118411].message }}
  • Profile picture of the author MikeHayes
    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
    Signature

    * * * * My site * * * *
    * * * * My paintings * * * *

    {{ DiscussionBoard.errors[4124078].message }}
  • Profile picture of the author AdWorkMedia
    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);
    Signature


    AdWork Media » Global Affiliate Network & Content Locking Solutions

    Custom Platform, Flexible Lockers, Offers For Every Country
    {{ DiscussionBoard.errors[4150021].message }}

Trending Topics