Re: Help Needed with MySQL Query

From: Date: Fri, 18 Apr 2003 18:43:41 +0000
Subject: Re: Help Needed with MySQL Query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144427@lists.php.net to get a copy of this message
Hello, use if($num_rows4 !=0){
      echo "NUM_ROWS_4<br>";
      while ($qry1 = mysql_fetch_array($result4)){
          $list1[] = $qry1['e_mail'];
     }
} and drop the explode statement. You're exploding on a space, but you separated the emails with a \n, so explode would return an array with a single element containing every email separated by \n. Now you can remove the ereg_replace() right before the mail() statement. If you still want the list in string form use: echo "this is the list:\n\n" . join("\n",$list1); Regards, Greg -- phpDocumentor http://www.phpdoc.org Pushpinder Singh Garcha wrote:
Hello All, I am trying to send email to some people depending on the outcome of a query. Here is a code snippet. This snippet is part of the code that will be run daily to check the validity of Login Names on the basis of number of days that are left in their cycle. After getting the list of email addresses in form of an array $email_list, I try to explode the list with an aim of sending a mail to each contact. For some reason, there is a error in the last part of the code and hence email is not sent to the contacts. // START OF PHP-CODE $string4 = "SELECT e_mail from test where priv_level = 0 AND informed = 'NULL' ";
  $result4 = mysql_query($string4)              or die (mysql_error());
$num_rows4 = mysql_num_rows($result4); if($num_rows4 !=0){
     echo "NUM_ROWS_4<br>";
     while ($qry1 = mysql_fetch_array($result4)){
         $list1 .= $qry1['e_mail']."\n";
    }
} echo "This is the list: <br>".$list1."<br>"; // echo "Count of this list is : ".count($list1); $body = "Please note that your login has expired and you will no longer be able to use the MasterStream "; $body .= "Website. Please contact your CMI to get a new Passport Number and use that to login to the site"; $body .= "Many Thanks"; $body .= "Admin";
  $subject2       = "Notification of Passport Expiration";
  $msg2           = $body;     $mailheaders2   = "From: MasterStream Administrator\n";
$mailheaders2 .= "Reply-To: $email_return \n\n"; $email_list = explode(" ", $list1); echo "COUNT IS NOW == ".count($email_list)."<br>"; echo "<br>HERE is the first array element ".$email_list[1]."<br>"; for($index = 0; $index < count($email_list); $index++)
     {
       $email_list[$index] = ereg_replace("\n", "", $email_list[$index]);
       mail($email_list[$index], $subject2, $msg2, $mailheaders2);
     }
Thanks in advance. --Pushpinder Garcha


« previous php.general (#144427) next »