Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1047051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:14:35+00:00 2026-05-16T16:14:35+00:00

I have a (PHP) script which runs on a new row in MySQL. However,

  • 0

I have a (PHP) script which runs on a new row in MySQL. However, it will continually send the emails, even if they’ve already been sent…causing mass emails into the users Inbox.

The script is quite big, so I cant paste it here – http://pastebin.com/6v75F4Gv

Is there anyway I can somehow check if this script has already sent ‘xx’ email, but if a new row containing ‘zz’ and the user has specified they wish to receive content containing ‘zz’ it sends the ‘zz’ row?

ie. It stops duplicate/etc. emails.

Note: MySQL table is in the following format:
Table: feed
Rows in pager: id, title, description, date

Table: recipients
Rows in recipients: id, email, suburb

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:14:35+00:00Added an answer on May 16, 2026 at 4:14 pm

    Neither of your tables has a column to log if the email has been sent, which is what I’d expect to see happen here:

    if (sendMail($subject, $to, $body, $from, $cc))
    {
       echo 'Mail for ' . $to . ' has been sent.<br />';
    
       //Update database so only one email is sent...
       $sql = "INSERT INTO TRACKING_TABLE 
                  (feed_id, recipient_id, isSent)
               VALUES
                  ($feed_id, $recip_id, 'Y')";
       $query = mysql_query($sql);
    } else
    {  ...
    

    …which would mean updating:

    $feed_sql = "SELECT id, title, description, rssDate 
                   FROM feed 
                  WHERE MATCH (title) AGAINST ('" . $rows['suburb'] . "') 
                    AND NOT EXISTS(SELECT NULL
                                     FROM TRACKING_TABLE tt
                                    WHERE tt.feed_id = feed.id
                                      AND tt.recipient_id = $Recipient_id
                                      AND tt.issent = 'Y')
               GROUP BY pubDate 
               ORDER BY pubDate DESC 
                  LIMIT 1";
    

    …to be sure that your query isn’t picking up those that have been successfully sent.

    DROP TABLE IF EXISTS `example`.`tracking_table`;
    CREATE TABLE  `example`.`tracking_table` (
      `feed_id` int(10) unsigned NOT NULL default '0',
      `recipient_id` int(10) unsigned NOT NULL default '0',
      `issent` char(1) NOT NULL default '',
      PRIMARY KEY  (`feed_id`,`recipient_id`),
      FOREIGN KEY (feed_id) REFERENCES pager(id),
      FOREIGN KEY (recipient_id) REFERENCES recipients(id)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in html which runs a php script whitch inserts text
I have a scheduled task on my server which runs a PHP script every
I have tried a session.php script which runs at the head of each page
i have a php script which runs fine when executed by SSHing into my
I have a php script which runs continuously several hours and every few seconds
I have the following PHP script which runs nicely and inserts all the data
I have this PHP script which i'm grabbing images from a directory and displaying
I have a php script which saves the original image, then resizes it -
I have a PHP script which creates and listens on a port for connections
I have a PHP script which is generating buttons to each content schedule. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.