Daniel-

I just tried this, didn't seem to make a difference.

Thanks for the reply!

        Bryan

On Tue, 25 Mar 2003, daniel wrote:

|hi , i have had similar issues its worked by doing a ob_flush before flush
|then u want a sleep statement so maybe try
|
|ob_flush();
|flush();
|sleep(2);
|
|??
|
|>===== Original Message From Bryan Koschmann - GKT <[EMAIL PROTECTED]> =====
|>Hello,
|>
|>I'm including a script I use to automatically e-mail overdue customers. My
|>problem is I have to have it sleep to avoid upsetting the mailserver, but
|>when I do, it seems to pause and sleep the total time (number of users x
|>sleep(1)) then output the whole block. I'm testing it now by printing the
|>name and email to the screen.
|>
|>Instead of:
|>
|>Customer 1 - [EMAIL PROTECTED]
|>pause 1 sec
|>Customer 2 - [EMAIL PROTECTED]
|>pause 1 sec
|>Customer 3 - [EMAIL PROTECTED]
|>pause 1 sec
|>
|>I get
|>
|>big big big pause
|>Customer 1 - [EMAIL PROTECTED]
|>Customer 2 - [EMAIL PROTECTED]
|>Customer 3 - [EMAIL PROTECTED]
|>
|>
|>Here is the script. Any help would be great!
|>
|>Thanks,
|>
|>      Bryan
|>
|>
|>
|><?php
|>
|>$myname = "My Company";
|>$myemail = "[EMAIL PROTECTED]";
|>
|>$now = strtotime("now");
|>$nowdate = date("l, F jS Y", $now);
|>$nowtime = date("H:i", $now);
|>$nowmonth = date("F", $now);
|>$nowyear = date("Y", $now);
|>
|>$duedate = strtotime("25 $nowmonth $nowyear");
|>$duedate = date("l, F jS Y", $duedate);
|>
|>$t = mktime(0,0,0,date('m')+1,1,date('Y'));
|>$expdate = date("l, F jS Y", $t);
|>
|>$expdatenum = date("w", $t);
|>
|>if ($expdatenum == "6") {
|>        $rendate = date("l, F jS Y", strtotime("$expdate +2 days"));
|>} else {
|>        $rendate = date("l, F jS Y", strtotime("$expdate +1 day"));
|>}
|>
|>
|>$query = htmlspecialchars("execute goToExpire");
|>
|>$fp = fsockopen ("111.222.333.444", 45678, $errno, $errstr, 30);
|>
|>// return_format can be either "delimited" or "xml"
|>$connect = "
|><request>
|>      <connect>
|>              Provider=SqlOleDb;
|>              Data Source=(local);
|>              Initial Catalog=MyCompany;
|>              Integrated Security=SSPI;
|>      </connect>
|>      <options>
|>              <return_format>delimited</return_format>
|>              <delimiter>~</delimiter>
|>              <text_qualifier></text_qualifier>
|>      </options>
|>      <query>
|>              $query
|>      </query>
|></request>
|>";
|>
|>$usercount = "0";
|>
|>if (!$fp) {
|>      echo "$errstr ($errno)<br>\n";
|>} else {
|>      fputs ($fp, "$connect");
|>      flush();
|>
|>      // Create some headings for the table
|>
|>      while (!feof($fp)) {
|>              $buffer = fgets($fp, 4096);
|>              $row = explode('~', $buffer);
|>
|>              if (!empty($row[0])) {
|>                      if ($row[0] == "ERROR") {
|>                              echo "<font face=arial size=5 
color=#ff0000><b>$row[0]: $row[1]
|$row[2]</b></font>\n";
|>                      } else {
|>                              if (username($row[4]) !== "") {
|>
|>                              $isbiz = str_replace("\r\n", "", $row[6]);
|>                              $accountnum = account($row[0]);
|>                              $amountdue = amount($row[5]);
|>
|>                              if ($isbiz == "True") {
|>                                      $fullname = name($row[1]);
|>                              } elseif ($isbiz == "False") {
|>                                      if (miname($row[3]) == "") {
|>                                              $fullname = name($row[2]) . " " . 
name($row[1]);
|>                                      } else {
|>                                      $fullname = name($row[2]) . " " . 
miname($row[3]) . " " . name($row[1]);
|>                                      }
|>                              }
|>                              flush();
|>                              $subject = "Account Status: #" . account($row[0]);
|>                              $message =      "\r\n" .
|>                                              "$fullname\r\n" .
|>                                              "Account #" . account($row[0]) . 
"\r\n\r\n" .
|>                                              "Payment Reminder!\r\n\r\n" .
|>                                              "Our records indicate that we have not 
received your payment of
|\$$amountdue due\r\n" .
|>                                              "on $duedate for your Internet access 
account. Please\r\n" .
|>                                              "send in your payment to prevent any 
interruption in your service.
|Any\r\n" .
|>                                              "accounts with an open balance will 
expire on $expdate\r\n" .
|>                                              "at 5:00pm, and cannot be reactivated 
until $rendate at
|9:00am.\r\n\r\n" .
|>                                              "If you have already sent in payment, 
please disregard this reminder.
|If\r\n" .
|>                                              "you believe your account to be 
up-to-date or believe this message to
|be in\r\n" .
|>                                              "error, feel free to call us at (555) 
123-4567 or reply to this message
|to\r\n" .
|>                                              "discuss your account.\r\n\r\n\r\n" .
|>                                              "\tMy COmpany\r\n" .
|>                                              "\tBilling Department\r\n\r\n" .
|>                                              "[$nowdate - $nowtime]";
|>
|>                              $custemail = username($row[4]) . "@domain.com";
|>                              $headers = "From: ".$myname." <".$myemail.">\r\n";
|>                              $headers .= "To: \"" . htmlspecialchars($fullname) . 
"\"
|<$custemail>\r\n";
|>                              $headers .= "X-Mailer: Caesar-PHP";
|>                              echo "Sending mail to $fullname - $custemail\n";
|>                              // mail($custemail, $subject, $message, $headers);
|>                              // echo "$headers\n$subject\n$message\n";
|>                              $usercount++;
|>                              flush();
|>                              usleep(50000);
|>
|>                              }
|>                      }
|>              }
|>
|>      }
|>      fclose ($fp);
|>      echo "$usercount overdue customers\n";
|>}
|>
|>function username($username) {
|>      $name = str_replace(" ", "", $username);
|>      $name = str_replace(",", "", $username);
|>      $name = strtolower($username);
|>      return $username;
|>}
|>
|>function amount($amount) {
|>      $amount = number_format($amount, 2);
|>      return $amount;
|>}
|>
|>function name($name) {
|>//    $name = str_replace("\"", "", $name);
|>      $name = str_replace(",", "", $name);
|>      $name = ucwords(strtolower($name));
|>      return $name;
|>}
|>
|>function miname($name) {
|>      $name = str_replace(" ", "", $name);
|>      $name = str_replace(",", "", $name);
|>      $name = ucwords(strtolower($name));
|>      return $name;
|>}
|>
|>function account($num) {
|>//    $num = str_replace("\"", "", $num);
|>      $num = str_replace("12:00:00 AM", "", $num);
|>      $num = str_pad($num, 8, 0, STR_PAD_LEFT);
|>      return $num;
|>}
|>
|>
|>?>
|>
|>
|>--
|>PHP General Mailing List (http://www.php.net/)
|>To unsubscribe, visit: http://www.php.net/unsub.php
|
|
|
|


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to