By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Getting 3 emails from one mail()

P: n/a
Wm
I'm totally clueless on this one -- I'm getting 3 copies of every Email (in
plain text, not HTML as expected), from a single mail() line... Can anyone
tell me what might be causing the duplicates??

Thanx!
Wm
<?PHP
include('dbconn.php');
$query="SELECT
artistID,active,email,firstname,lastname,city,stat e,mentor from artists
WHERE artistID='$artistID'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
while($row = mysql_fetch_array($result)) {
$email = $row['email'];
$notactive = $row['active'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$city = $row['city'];
$state = $row['state'];
$mentor = $row['mentor'];

if ($mentor == "1") {
$class = "as a Mentor";
}
else {
$class = "as an Assistant";
}

if (($notactive == "0") AND ($ver == "1")) {
mysql_query("UPDATE artists SET active='1' WHERE artistID =
'$artistID' LIMIT 1");
echo "Your listing has been successfully activated -- welcome to
Makeup Mentors!<BR>
Please tell a friend about this resource!";
// generate Email
$headers = "From: domain.com <We*******@domain.com>\n";
$headers .= "X-Sender: <We*******@domain.com>\n";
$headers .= "X-Mailer: domain.com\n"; //mailer
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <We*******@domain.com>\n";
$headers .= "bcc: ma**@herdomain.com";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$city = stripslashes($city);
$message = "
<p align=\"left\">domain.com has just activated the following artist
$class:</p>
<p align=\"left\">Name: $firstname $lastname<br>
Location: $city, $state</p>
<p>&nbsp;</p>
<p align=\"left\">Webmaster<br>
<A HREF=\"http://www.domain.com\">www.domain.com</A></p>";
$subject = "Makeup Mentors listing verification";
$to = "wi*****@mydomain.net";
mail($to, $subject, $message, $headers);
}
else if (($active > 0) AND ($ver == "1")) {
echo "Your listing is already activated.<BR>";
}
}
?>
Jul 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"Wm" <LA*******@hotmail.com> schreef in bericht
news:nV**********************@news.easynews.com...
I'm totally clueless on this one -- I'm getting 3 copies of every Email (in plain text, not HTML as expected), from a single mail() line... Can anyone
tell me what might be causing the duplicates??

Thanx!
Wm

Hmm I dont have the time to figure out the { {{{{ }}}}} part .... maybe u
should try some structure.
did u try a echo msql_num_rows($result); ? maybe u will find ur getting 3
results for some odd reason. Did u set primary key unique ?

Cya

Floortje
Jul 16 '05 #2

P: n/a
Wm
"floortje" <fl******@floortje.floortje> wrote in message
news:3f***********************@dreader8.news.xs4al l.nl...
"Wm" <LA*******@hotmail.com> schreef in bericht
news:nV**********************@news.easynews.com...
I'm totally clueless on this one -- I'm getting 3 copies of every Email (in plain text, not HTML as expected), from a single mail() line... Can anyone tell me what might be causing the duplicates??

Hmm I dont have the time to figure out the { {{{{ }}}}} part .... maybe u
should try some structure.
did u try a echo msql_num_rows($result); ? maybe u will find ur getting 3
results for some odd reason. Did u set primary key unique ?

Cya

Floortje


Yes, I have an autonumber field as a primary key. Every single registrant is
generating exactly 3 emails so I know that it's not duplicate records, it
must be something about my code that is looping...??

Wm
Jul 16 '05 #3

P: n/a

"Wm" <LA*******@hotmail.com> schreef in bericht
news:ri********************@news.easynews.com...
"floortje" <fl******@floortje.floortje> wrote in message
news:3f***********************@dreader8.news.xs4al l.nl...
"Wm" <LA*******@hotmail.com> schreef in bericht
news:nV**********************@news.easynews.com...
I'm totally clueless on this one -- I'm getting 3 copies of every
Email
(in plain text, not HTML as expected), from a single mail() line... Can anyone tell me what might be causing the duplicates??
Hmm I dont have the time to figure out the { {{{{ }}}}} part .... maybe u should try some structure.
did u try a echo msql_num_rows($result); ? maybe u will find ur getting 3 results for some odd reason. Did u set primary key unique ?

Cya

Floortje


Yes, I have an autonumber field as a primary key. Every single registrant

is generating exactly 3 emails so I know that it's not duplicate records, it
must be something about my code that is looping...??

Did u try msql_num_rows($result); ?? U could try print_r($result); ... that
will give ya more info on the content of the array
Jul 16 '05 #4

P: n/a
On Thu, 28 Aug 2003 15:13:51 +0200
"floortje" <fl******@floortje.floortje> wrote:

<snip>
generating exactly 3 emails so I know that it's not duplicate
records, it must be something about my code that is looping...??

Did u try msql_num_rows($result); ?? U could try print_r($result); ...
that will give ya more info on the content of the array

Do you mean print_r($row) ? $result is not an array, its an integer.
Matt
--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9688 2894 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #5

P: n/a
Just wondering: why even have a while() if you only expect one result?

--
// DvDmanDT
MSN: dv******@hotmail.com
Mail: dv******@telia.com
"kicksy" <sl********@blueyonder.co.ukNOSPAM> skrev i meddelandet
news:Y4*********************@news-text.cableinet.net...

"Wm" <LA*******@hotmail.com> wrote in message
news:nV**********************@news.easynews.com...
I'm totally clueless on this one -- I'm getting 3 copies of every Email

(in
plain text, not HTML as expected), from a single mail() line... Can anyone tell me what might be causing the duplicates??

Thanx!
Wm
<?PHP
include('dbconn.php');
$query="SELECT
artistID,active,email,firstname,lastname,city,stat e,mentor from artists
WHERE artistID='$artistID'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));


I'm gonna suggest doing this.
$row=mysql_fetch_array($result);
if (mysql_num_rows($row)==1)//1 result returned
{
// while loop
}
else
{
echo "too many results returned";
}

This way you can see if you are getting too many...
:P
while($row = mysql_fetch_array($result)) {
$email = $row['email'];
$notactive = $row['active'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$city = $row['city'];
$state = $row['state'];
$mentor = $row['mentor'];

if ($mentor == "1") {
$class = "as a Mentor";
}
else {
$class = "as an Assistant";
}

if (($notactive == "0") AND ($ver == "1")) {
mysql_query("UPDATE artists SET active='1' WHERE artistID =
'$artistID' LIMIT 1");
echo "Your listing has been successfully activated -- welcome to Makeup Mentors!<BR>
Please tell a friend about this resource!";
// generate Email
$headers = "From: domain.com <We*******@domain.com>\n";
$headers .= "X-Sender: <We*******@domain.com>\n";
$headers .= "X-Mailer: domain.com\n"; //mailer
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <We*******@domain.com>\n";
$headers .= "bcc: ma**@herdomain.com";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$city = stripslashes($city);
$message = "
<p align=\"left\">domain.com has just activated the following artist $class:</p>
<p align=\"left\">Name: $firstname $lastname<br>
Location: $city, $state</p>
<p>&nbsp;</p>
<p align=\"left\">Webmaster<br>
<A HREF=\"http://www.domain.com\">www.domain.com</A></p>";
$subject = "Makeup Mentors listing verification";
$to = "wi*****@mydomain.net";
mail($to, $subject, $message, $headers);
}
else if (($active > 0) AND ($ver == "1")) {
echo "Your listing is already activated.<BR>";
}
}
?>


Jul 16 '05 #6

P: n/a
Wm
"DvDmanDT" <dv******@telia.com> wrote in message
news:zz*******************@newsc.telia.net...
Just wondering: why even have a while() if you only expect one result?

--
// DvDmanDT
MSN: dv******@hotmail.com
Mail: dv******@telia.com
"kicksy" <sl********@blueyonder.co.ukNOSPAM> skrev i meddelandet
news:Y4*********************@news-text.cableinet.net...

Good question! That's the way I've done other queries, so I copied the lines
that worked on other pages. I still get confused on all the options for
fetch_array, etc...

BTW, I'm still getting 1 result from the query, yet consistently receiving 3
emails...

Wm
"Wm" <LA*******@hotmail.com> wrote in message
news:nV**********************@news.easynews.com...
I'm totally clueless on this one -- I'm getting 3 copies of every Email
(in
plain text, not HTML as expected), from a single mail() line... Can
anyone tell me what might be causing the duplicates??

Thanx!
Wm
<?PHP
include('dbconn.php');
$query="SELECT
artistID,active,email,firstname,lastname,city,stat e,mentor from
artists WHERE artistID='$artistID'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));


I'm gonna suggest doing this.
$row=mysql_fetch_array($result);
if (mysql_num_rows($row)==1)//1 result returned
{
// while loop
}
else
{
echo "too many results returned";
}

This way you can see if you are getting too many...
:P
while($row = mysql_fetch_array($result)) {
$email = $row['email'];
$notactive = $row['active'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$city = $row['city'];
$state = $row['state'];
$mentor = $row['mentor'];

if ($mentor == "1") {
$class = "as a Mentor";
}
else {
$class = "as an Assistant";
}

if (($notactive == "0") AND ($ver == "1")) {
mysql_query("UPDATE artists SET active='1' WHERE artistID =
'$artistID' LIMIT 1");
echo "Your listing has been successfully activated -- welcome to Makeup Mentors!<BR>
Please tell a friend about this resource!";
// generate Email
$headers = "From: domain.com <We*******@domain.com>\n";
$headers .= "X-Sender: <We*******@domain.com>\n";
$headers .= "X-Mailer: domain.com\n"; //mailer
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <We*******@domain.com>\n";
$headers .= "bcc: ma**@herdomain.com";
$headers .= "Content-Type: text/html;
charset=iso-8859-1\n"; $city = stripslashes($city);
$message = "
<p align=\"left\">domain.com has just activated the following

artist $class:</p>
<p align=\"left\">Name: $firstname $lastname<br>
Location: $city, $state</p>
<p>&nbsp;</p>
<p align=\"left\">Webmaster<br>
<A HREF=\"http://www.domain.com\">www.domain.com</A></p>";
$subject = "Makeup Mentors listing verification";
$to = "wi*****@mydomain.net";
mail($to, $subject, $message, $headers);
}
else if (($active > 0) AND ($ver == "1")) {
echo "Your listing is already activated.<BR>";
}
}
?>



Jul 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.