Jump to content


Photo

How to code a wait


  • Please log in to reply
3 replies to this topic

#1 momath

momath
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 21 August 2006 - 08:17 PM

Hi,

here is my code:

$result = mysql_query("SELECT email FROM $database_table") or die ("$header<br><br><center><font color=\"#FFFF00\" size=\"3\"><img title=Warning! border=0 src=images/warn.gif>$error_mysql_query</font><br><br><img title=FYI border=0 src=images/info.gif>Help Info: Make sure you have edited the config.php file correctly.</font><br><br><a title='Go Back' href=javascript:history.go(-1)><font color=\"#FFFFFF\" size=\"3\">[ Go Back ]</font></a></center>");
$recordnum = mysql_num_rows($result);
print "$header<br><br><center><font color=#FFFFFF size=3>$recordnum HTML emails were succesfully sent. Here is a list:</font><br>";
while ($qry = mysql_fetch_array($result)) {
$email = $qry[email];
$headers = "From: $company_name <$contact_email>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
$headers .= "X-Mailer: PHP \n";
$message = "$htmlbody<br><br>";
$optoutlink  = "http://www.zoneski.com/concours";
$optoutlink .= '/unsubscribe.php?action=unsub&email=';
$optoutlink .= "$email";
$message .= "<font color=#ffffff size=2 face=arial>$optoutmessage</font><br>";
$message .= "<font size=2 face=arial><a target=\"_blank\" href=$optoutlink>Cliquez ici pour ne plus recevoir de courriel de notre part.<a></font><br>";
mail($email, $subject, $message, $headers);
print "$email<br>";

}}}


I want to add something so that every 50 transactions or so, it does somekind of a wait of 15 seconds let's say.  This way, my php-sendmail works real fine for all of my 2000 people.

Thanks in advance

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 August 2006 - 08:25 PM

...
mail($email, $subject, $message, $headers);
$xyz++;
if ($xyz==50) { sleep(15); $xyz=0;}
...

Legend has it that reading the manual never killed anyone.
My site

#3 momath

momath
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 21 August 2006 - 09:01 PM

Thanks,  now I have a second problem, since this page is long to load (it takes a lot of time); how can I prevent my browser to get a timeout?  How could I send something on the screen?

As you can see I am modifying existing code and I dont know a lot about PHP.

#4 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 August 2006 - 09:09 PM

why not simply create a string of all the recipients and use that in BCC: field of the headers - it should be very quick then you will only call mail once! there will still be a big load on the server BUT you could look for the tutorial on forking to see if that will help you.
follow me on twitter @PHPsycho




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users