So I am going thorugh another tutorial, but it appears that it may be outdated.
basically the script gets data from mysql db (title and content) and inserts into an email message for users also provided by mysql (whose subscribe status = 1)
I am not getting any mysql errors, so am thinking that the tut (I) may be using has outtdated code.
I am just getting presented with the final "Email sent to" line, but no $email variable is placed, and no email gets sent.
Your help and time is greatly appreciated,
jojo
?php
// set time limit to 15 minutes (900/60)
set_time_limit(900);
include("connect.php");
$id = preg_replace("/'\/<>\"/","",$_GET['id']);
if (empty($id))
die("Invalid ID");
$link = "SELECT * FROM newsletters WHERE id='$id'";
$res = mysql_query($link) or die(mysql_error());
$r = mysql_fetch_assoc($res);
$subject = $r['name'];
$message = $r['content'];
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Me@n3wb.com' . "\r\n" .
'Reply-To: notme@n3wb.com' . "\r\n" .
//'X-Mailer: PHP/' . phpversion();
$link = "SELECT * FROM users WHERE status='subscribed'";
$res = mysql_query($link) or die(mysql_error());
while ($r = mysql_fetch_row($res))
{
$email = $r['email'];
$mail = mail($email, $subject, $message, $headers);
}
if ($mail)
{
echo "Email sent to " . $email . '<br>';
die;
}
else
{
echo "Error in mailing " . $email . '<br>';
die;
}
?>