Hi, I have a situation where our site sends out email alerts. I didn't write the scripts but am trying to adjust. When someone signs up for email alerts in a certain category, their email gets stuffed in a field in the database, and it's separated by ~~~. So the email field in the alerts database could have multiple emails in there.

I've setup a bademails table that we can store bounced emails. I want to check that table, then remove any emails from the alerts table. Here's what I have, but something is wrong with my loop. It stops after finding one record.

###### $SQL = "Select * from bademails ORDER BY ID DESC"; &Do_SQL; while ($pointer = $sth->fetchrow_hashref) { $bademail = $pointer->{'email'}; $SQL2 = "Select * from $alertstable where email LIKE '%$bademail%' +"; &Do_SQL2; $item = $pointer2->{'type'}; $alertype = $pointer2->{'alertype'}; $emaillist = $pointer2->{'email'}; $ID = $pointer2->{'ID'}; @emails = split /~~~/,$emaillist; foreach $address (@emails) { print "$ID<Br>\n"; $elist = ""; if ($address eq $bademail) { $elist = $elist . $address . "~~~"; } } $SQL3 = "UPDATE $alertstable SET email='$elist' WHERE type='$item' +and alerttype='$alerttype'"; &Do_SQL3; print "Updated $ID<Br>\n"; } # end while #######################

In reply to Comparing 2 databases by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.