Hi all, This test code runs through an array of email addresses with the goal of stopping every 20 rows for 60 seconds. <?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); } } ?> PHP: 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
Error line 1: echo $mails['e_mail'],'br /'; should be: echo $mails['e_mail'].'<br />'; Erorr line 2: if $counter = $last { should be: if($counter == $last){ correct code, hopefully: <?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); } } ?> PHP: Also, keep in mind that long pause can cause your script to timeout, if you dont set it accordingly in PHP ini..
Default timeout for any php script is 30 seconds, If you pause your script for more than the timeout you will get a So if you need to pause your script for longer durations, set the timeout value accordingly in PHP ini.
The Webby is correct. You can also use htaccess and set php max_execution_time if you do not have direct access to php.ini or don't want all your scripts execution time to be effected. Sometimes it is smart to timeout, as it can put heavy load on the server.
Thanks everyone for your contributions and help. The problem has gone away as I don't need the pause anymore. Mike