Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.