Getting 3 emails from one mail()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wm

    Getting 3 emails from one mail()

    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,firstnam e,lastname,city ,state,mentor from artists
    WHERE artistID='$arti stID'";
    $result=mysql_q uery($query) or die(mysql_error ("Could not execute
    query."));
    while($row = mysql_fetch_arr ay($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("UP DATE 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 <Webmaster@doma in.com>\n";
    $headers .= "X-Sender: <Webmaster@doma in.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: <Webmaster@doma in.com>\n";
    $headers .= "bcc: mary@herdomain. com";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n";
    $city = stripslashes($c ity);
    $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.co m</A></p>";
    $subject = "Makeup Mentors listing verification";
    $to = "william@mydoma in.net";
    mail($to, $subject, $message, $headers);
    }
    else if (($active > 0) AND ($ver == "1")) {
    echo "Your listing is already activated.<BR>" ;
    }
    }
    ?>


  • floortje

    #2
    Re: Getting 3 emails from one mail()


    "Wm" <LAshooter@hotm ail.com> schreef in bericht
    news:nVd3b.3140 344$mA4.430269@ news.easynews.c om...[color=blue]
    > I'm totally clueless on this one -- I'm getting 3 copies of every Email[/color]
    (in[color=blue]
    > plain text, not HTML as expected), from a single mail() line... Can anyone
    > tell me what might be causing the duplicates??
    >
    > Thanx!
    > Wm
    >
    >[/color]
    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


    Comment

    • Wm

      #3
      Re: Getting 3 emails from one mail()

      "floortje" <floortje@floor tje.floortje> wrote in message
      news:3f4db753$0 $76465$e4fe514c @dreader8.news. xs4all.nl...[color=blue]
      > "Wm" <LAshooter@hotm ail.com> schreef in bericht
      > news:nVd3b.3140 344$mA4.430269@ news.easynews.c om...[color=green]
      > > I'm totally clueless on this one -- I'm getting 3 copies of every Email[/color][/color]
      (in[color=blue][color=green]
      > > plain text, not HTML as expected), from a single mail() line... Can[/color][/color]
      anyone[color=blue][color=green]
      > > tell me what might be causing the duplicates??
      > >[/color]
      > 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[/color]

      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


      Comment

      • floortje

        #4
        Re: Getting 3 emails from one mail()


        "Wm" <LAshooter@hotm ail.com> schreef in bericht
        news:rim3b.3259 0$hf5.177492@ne ws.easynews.com ...[color=blue]
        > "floortje" <floortje@floor tje.floortje> wrote in message
        > news:3f4db753$0 $76465$e4fe514c @dreader8.news. xs4all.nl...[color=green]
        > > "Wm" <LAshooter@hotm ail.com> schreef in bericht
        > > news:nVd3b.3140 344$mA4.430269@ news.easynews.c om...[color=darkred]
        > > > I'm totally clueless on this one -- I'm getting 3 copies of every[/color][/color][/color]
        Email[color=blue]
        > (in[color=green][color=darkred]
        > > > plain text, not HTML as expected), from a single mail() line... Can[/color][/color]
        > anyone[color=green][color=darkred]
        > > > tell me what might be causing the duplicates??
        > > >[/color]
        > > Hmm I dont have the time to figure out the { {{{{ }}}}} part .... maybe[/color][/color]
        u[color=blue][color=green]
        > > should try some structure.
        > > did u try a echo msql_num_rows($ result); ? maybe u will find ur getting[/color][/color]
        3[color=blue][color=green]
        > > results for some odd reason. Did u set primary key unique ?
        > >
        > > Cya
        > >
        > > Floortje[/color]
        >
        > Yes, I have an autonumber field as a primary key. Every single registrant[/color]
        is[color=blue]
        > generating exactly 3 emails so I know that it's not duplicate records, it
        > must be something about my code that is looping...??
        >[/color]
        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


        Comment

        • Matthew Vickers

          #5
          Re: Getting 3 emails from one mail()

          On Thu, 28 Aug 2003 15:13:51 +0200
          "floortje" <floortje@floor tje.floortje> wrote:

          <snip>
          [color=blue][color=green]
          > > generating exactly 3 emails so I know that it's not duplicate
          > > records, it must be something about my code that is looping...??
          > >[/color]
          > 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[/color]


          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

          Comment

          • DvDmanDT

            #6
            Re: Getting 3 emails from one mail()

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

            --
            // DvDmanDT
            MSN: dvdmandt@hotmai l.com
            Mail: dvdmandt@telia. com
            "kicksy" <slapkicksy@blu eyonder.co.ukNO SPAM> skrev i meddelandet
            news:Y4n3b.6544 $us2.61719595@n ews-text.cableinet. net...[color=blue]
            >
            > "Wm" <LAshooter@hotm ail.com> wrote in message
            > news:nVd3b.3140 344$mA4.430269@ news.easynews.c om...[color=green]
            > > I'm totally clueless on this one -- I'm getting 3 copies of every Email[/color]
            > (in[color=green]
            > > plain text, not HTML as expected), from a single mail() line... Can[/color][/color]
            anyone[color=blue][color=green]
            > > tell me what might be causing the duplicates??
            > >
            > > Thanx!
            > > Wm
            > >
            > >
            > > <?PHP
            > > include('dbconn .php');
            > > $query="SELECT
            > > artistID,active ,email,firstnam e,lastname,city ,state,mentor from artists
            > > WHERE artistID='$arti stID'";
            > > $result=mysql_q uery($query) or die(mysql_error ("Could not execute
            > > query."));[/color]
            >
            > I'm gonna suggest doing this.
            > $row=mysql_fetc h_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[color=green]
            > > while($row = mysql_fetch_arr ay($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("UP DATE artists SET active='1' WHERE artistID =
            > > '$artistID' LIMIT 1");
            > > echo "Your listing has been successfully activated -- welcome[/color][/color]
            to[color=blue][color=green]
            > > Makeup Mentors!<BR>
            > > Please tell a friend about this resource!";
            > > // generate Email
            > > $headers = "From: domain.com <Webmaster@doma in.com>\n";
            > > $headers .= "X-Sender: <Webmaster@doma in.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: <Webmaster@doma in.com>\n";
            > > $headers .= "bcc: mary@herdomain. com";
            > > $headers .= "Content-Type: text/html; charset=iso-8859-1\n";
            > > $city = stripslashes($c ity);
            > > $message = "
            > > <p align=\"left\"> domain.com has just activated the following[/color][/color]
            artist[color=blue][color=green]
            > > $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.co m</A></p>";
            > > $subject = "Makeup Mentors listing verification";
            > > $to = "william@mydoma in.net";
            > > mail($to, $subject, $message, $headers);
            > > }
            > > else if (($active > 0) AND ($ver == "1")) {
            > > echo "Your listing is already activated.<BR>" ;
            > > }
            > > }
            > > ?>
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Wm

              #7
              Re: Getting 3 emails from one mail()

              "DvDmanDT" <dvdmandt@telia .com> wrote in message
              news:zz24b.2625 8$dP1.66398@new sc.telia.net...[color=blue]
              > Just wondering: why even have a while() if you only expect one result?
              >
              > --
              > // DvDmanDT
              > MSN: dvdmandt@hotmai l.com
              > Mail: dvdmandt@telia. com
              > "kicksy" <slapkicksy@blu eyonder.co.ukNO SPAM> skrev i meddelandet
              > news:Y4n3b.6544 $us2.61719595@n ews-text.cableinet. net...[color=green]
              > >[/color][/color]

              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


              [color=blue][color=green]
              > > "Wm" <LAshooter@hotm ail.com> wrote in message
              > > news:nVd3b.3140 344$mA4.430269@ news.easynews.c om...[color=darkred]
              > > > I'm totally clueless on this one -- I'm getting 3 copies of every[/color][/color][/color]
              Email[color=blue][color=green]
              > > (in[color=darkred]
              > > > plain text, not HTML as expected), from a single mail() line... Can[/color][/color]
              > anyone[color=green][color=darkred]
              > > > tell me what might be causing the duplicates??
              > > >
              > > > Thanx!
              > > > Wm
              > > >
              > > >
              > > > <?PHP
              > > > include('dbconn .php');
              > > > $query="SELECT
              > > > artistID,active ,email,firstnam e,lastname,city ,state,mentor from[/color][/color][/color]
              artists[color=blue][color=green][color=darkred]
              > > > WHERE artistID='$arti stID'";
              > > > $result=mysql_q uery($query) or die(mysql_error ("Could not execute
              > > > query."));[/color]
              > >
              > > I'm gonna suggest doing this.
              > > $row=mysql_fetc h_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[color=darkred]
              > > > while($row = mysql_fetch_arr ay($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("UP DATE artists SET active='1' WHERE artistID =
              > > > '$artistID' LIMIT 1");
              > > > echo "Your listing has been successfully activated --[/color][/color][/color]
              welcome[color=blue]
              > to[color=green][color=darkred]
              > > > Makeup Mentors!<BR>
              > > > Please tell a friend about this resource!";
              > > > // generate Email
              > > > $headers = "From: domain.com <Webmaster@doma in.com>\n";
              > > > $headers .= "X-Sender: <Webmaster@doma in.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: <Webmaster@doma in.com>\n";
              > > > $headers .= "bcc: mary@herdomain. com";
              > > > $headers .= "Content-Type: text/html;[/color][/color][/color]
              charset=iso-8859-1\n";[color=blue][color=green][color=darkred]
              > > > $city = stripslashes($c ity);
              > > > $message = "
              > > > <p align=\"left\"> domain.com has just activated the following[/color][/color]
              > artist[color=green][color=darkred]
              > > > $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.co m</A></p>";
              > > > $subject = "Makeup Mentors listing verification";
              > > > $to = "william@mydoma in.net";
              > > > mail($to, $subject, $message, $headers);
              > > > }
              > > > else if (($active > 0) AND ($ver == "1")) {
              > > > echo "Your listing is already activated.<BR>" ;
              > > > }
              > > > }
              > > > ?>
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              Working...