Hi all,
I am having this problem for the longest time. Hope you guys can solve it.
I'm running a community website where I send out weekly newsletters to all of my clients. However, I'm sure my hosting provider wouldn't be so happy if I just FOR LOOP and send it all out at once. SO what I did was I just a SLEEP and a header mthod that triggers after every second, where the header sends out GET variables for the next iteration to fetch at which account I am currently at to send the next newsletter.
Now the problem is this, I have about 250 people to send it to, since I set it to 1 second per newsletter sent, it would take 250 seconds for the page to finish loading. For some reason, my Firefox gives me a error after 19 newsletters have been sent out, saying that they detected a script that wouldn't be able to redirect anymore. I'm sure that they were thinking that they detected an infinite loop (which it wasn't).
So is there any better solution or a fix to my problem?
THANKS ALOT
$sleepTime = 1;
$dSendList =& $db->getAll( "SELECT DISTINCT id_account FROM subscription ORDER BY id_account" );
$countList = count($dSendList);
$expDuration = $countList * $sleepTime;
if (($_GET["action"] == "send") && ($_GET["nTimes"] < $countList - 1)) {
$nTimes = $_GET["nTimes"];
$Ruserid = $dSendList[$nTimes][id_account];
include_once "incrementNext.php"; // This includes the next URL
include_once 'send_events_emails.php'; // Script to generate newsletters
sleep($sleepTime);
header("Location: " . $urlLocation); /* Redirect browser */
exit;
}