Help with mailing from table in database?

Hi there,

I am not certain if this is the correct board, but here goes…

I am attempting to create a mailing list for my subscribers with PHP and MySQL.
I have a table called pb_subscribers, and it has three sections: subscriber_id, subscriber_name, and subscriber_address.
The subscriber_id will not be used when mailing the subscribers, but instead, it is used for when I want to delete a user.

Here’s my code:

$link = 'http://' . $_SERVER['HTTP_HOST'];
while ($row = mysql_fetch_assoc(mysql_query('SELECT * FROM pb_subscribers')) {
$to = $row['subscriber_name'] . '<' . $row['subscriber_address'] . '>';
}
$subject = $site->website_title_1() . " | New Post";
$emessage = "Hey there,\
\
A new post called \\"" . $_POST['title'] . "\\" has been posted on " . $site->website_title_1() . ".\
Go to " . $link . " to see the post!\
\
Thanks,\
Pocket Blogger";
$headers = "From: noone@pocket-blogger_com";
mail($to,$subject,$emessage,$headers);

Basically, I want “$to” to be equaled to all the values in the database, so I can mail the users. But, my code isn’t working… What am I doing wrong, and what can I do to fix this?

No one…?
I think my problem is that $to need to be an array…
Otherwise it will just select the first or last person in the table…

Help, anyone?

You can move the call to mail into the loop:


$link = 'http://' . $_SERVER['HTTP_HOST'];
$subject = $site->website_title_1() . " | New Post";
$emessage = "Hey there,\
\
A new post called \\"" . $_POST['title'] . "\\" has been posted on " . $site->website_title_1() . ".\
Go to " . $link . " to see the post!\
\
Thanks,\
Pocket Blogger";
$headers = "From: noone@pocket-blogger_com";

while ($row = mysql_fetch_assoc(mysql_query('SELECT * FROM pb_subscribers')) {
  $to = $row['subscriber_name'] . '<' . $row['subscriber_address'] . '>';
  mail($to, $subject, $emessage, $headers);
}

Thank you, it works.