Hi everyone.
I'm trying to send a message to everyone that I have in a database. The database has only one column. I'm just not sure how to get all of the names into the mail prototype mail($to, $subject, $message, $from). I tried to treat it like an array where it counts through the names, but that doesn't seem to work.
I have tried the code below, and it seems to process, showing no errors and telling me my mail was sent. However, not mail gets to my inbox when i'm testing this.
Does anyone see what I'm doing wrong?
<?php
// create short variable(s)
$txtSubject=$HTTP_POST_VARS['txtSubject'];
$txtMessage=$HTTP_POST_VARS['txtMessage'];
// database connection and error(s)
$dbh=mysql_connect ("localhost", "...", "...");
if (!$dbh)
{
echo "Not able to connect.";
exit;
}
// message
$message = "$txtMessage\n".$text;
// connect to database
mysql_select_db('...');
$query = "select * from [i]table[/i]";
$result = mysql_query($query);
$count = 0;
while($subscriber = mysql_fetch_row($result))
{
echo mysql_error();
mail($subscriber[1], $txtSubject, $message);
}
$count++;
mysql_error();
echo "your mail has been sent";
?>
Any help would be great!
Thanks,
Brian