First of all apologies if this has been posted before, having trouble findin the answer,

Let me start by inserting the code I have having the problem with, apologies if this isn't the correct way of doing things but I am still a newbie at php



$sql="SELECT * FROM db, 1st_reminder WHERE stage_two = '1' AND 2nd_email_sent = '0'"; 
$result = mysql_query($sql) or die(mysql_error());

$count = 1;
while ($rows = mysql_fetch_array ($result)) {

$to  = $rows['contact_email']; 
$from = "email@domain.com";
$subject = "Subject";
$message .= $rows['1st_body'];
$headers = "From:" . $from; 
    if ($count % 5 == 0) {
$sql="UPDATE db SET 2nd_email_sent ='1' WHERE 2nd_email_sent ='0'";


The issue I am having is if there is more than one email that goes out, (which will be the case once finished) the email is duplicated, so I get the email going to all the recipients but the body of the message is repeated, has any one got any ideas where I might be going wrong

This is a project I am working on for work, it generates email as reminders to customers, so it will be sending out several a day


Recommended Answers

All 4 Replies

Member Avatar
$message .= $rows['1st_body'];

should be

$message = $rows['1st_body'];

Is that right?

also maybe:

$sql="UPDATE db SET 2nd_email_sent ='1' WHERE 2nd_email_sent ='0' AND stage_two = '1'";

Thanks guys, this worked a dream

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.