Jump to content

Mailing list help.


maestrodamuz

Recommended Posts

I am developing a newsletter mailing application.

On testing i discovered that the application doesnt send a mail to the most recent added email, I have tried to debug the script to no avail

 

This is the script I am using

 

mysql_select_db($database_gedu, $gedu);
$query_users = "SELECT email FROM users ORDER BY sname DESC";
$users = mysql_query($query_users, $gedu) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);

//create a From: mailheader
$headers = "From:XXXXXXXXXXXX";

//loop through results and send mail
while ($row = mysql_fetch_array($users)) {
set_time_limit(0);
$email = $row['email'];

// content-type
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

mail("$email", stripslashes($_POST['subject']), stripslashes($_POST['body']), "$headers");
echo "Email has been sent to: $email<br>";
}

 

Any help will be aapreciated.

Link to comment
https://forums.phpfreaks.com/topic/142043-mailing-list-help/
Share on other sites

$row_users = mysql_fetch_assoc($users);

 

That is the line that is messing you up. Remove that and your script should work fine.

Thank U premiso...it works now..I appreciate ;D

 

If you want to know why, accessing that there set the pointer to be +1 so when you looped through it, it was under the impression you already accessed the first element. Anyhow I was just bored so figured I would explain it.

Link to comment
https://forums.phpfreaks.com/topic/142043-mailing-list-help/#findComment-743819
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.