I'm trying to mail everybody in my subscriber database. I'm trying to go through each PersonID but if people unsubscribe, rows will be missing from my database. It could go 1,2,5,9,10,11,15 etc.
How can I best accommodate this?
$pullEmails = mysql_query("SELECT COUNT(*) FROM Subscribe;");
while($pullEmails > 0))
{
$getEmail = mysql_query("SELECT Email from Subscribe where PersonID = " . $pullEmails . ";");
$subject = "Test mail";
$message = "test email to all the subscribers";
$from = "admin@codefundamentals.com";
$headers = "From:" . $from;
mail($getEmail,$subject,$message,$headers);
$pullEmails = $pullEmails - 1;
}
EDIT - I have this
$sql = mysql_query("select 'Email' from Subscribers");
$recipients = array();
while($row = mysql_fetch_array($sql)) {
$recipients[] = $row['Email'];
}
$to = 'admin@codefundamentals.com';
$subject = "E-mail subject";
$body = "E-mail body test. sorry everyone";
$headers = 'From: admin@codefundamentals.com' . "\r\n" ;
$headers .= 'BCC: ' . implode(', ', $recipients) . "\r\n";
mail($to, $subject, $body, $headers);
It's returning back
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home1/codefund/public_html/admin/submit.php on line 33 script finished
But I can't figure out why! Googling it gives me mysql_fetch_array() but I've incorporated that?