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 8962329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:06:16+00:00 2026-06-15T16:06:16+00:00

All bounced emails are sent to a table in my database. I am trying

  • 0

All bounced emails are sent to a table in my database. I am trying to compare them to a field in another table that is populated with my active emails. Using the following function it returns nothing when using “IN” and all when using “NOT IN”, but i know that there are matching emails in the two tables. am i going at this the wrong way?

<?php
function CompareEmails() {
    $mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);

    if ($mysqli->connect_errno) {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") ";
        echo $mysqli->connect_error;
        $mysqli->close();
    }

    $bademails = array();
    $values = $mysqli->query("SELECT bad_emails.emails FROM bad_emails ");

    while ($row = $values->fetch_assoc()) {
        $bademails[] = $row['emails'];
    }

    $query = "SELECT email_database.customer_id, email_database.email 
              FROM email_database 
              WHERE email_database.email IN('" . implode("' , '", $bademails) . "') 
              ORDER BY email_database.customer_id DESC";

    $values2 = $mysqli->query($query);

    while ($row2 = $values2->fetch_assoc()) {
        echo $row2['customer_id'] . " " . $row2['email'] . "</br>";                                                                                                            
    }                                                                                                                                                                          
}                                                                                                                                                                              
?>
  • 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-06-15T16:06:17+00:00Added an answer on June 15, 2026 at 4:06 pm

    You could do this all much more nicely in a single query like this:

    SELECT e.customer_id, e.email
    FROM email_database AS e
    INNER JOIN bad_emails AS b ON e.email = b.emails
    ORDER BY e.customer_id DESC
    

    Note that I used b.emails (plural) joined to e.email (singular) to match what you show in your queries. I am guessing that this might actually be the problem you are having in that you might be getting an empty result set if you are not referring to the field name correctly in bad_emails (is it really just email?). that would lead to the exact IN/NOT IN behavior you are seeing.

    Just change my query to use whatever the correct name is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to search all emails that bounced? i tried this. imap_search($inbox,SUBJECT failed) but it
I have a webpage that sends out emails using phpmailer. I set the host
All, If I've go the following database fields/values: user_id field_name field_value 1 EventHour1 1
All I want to do is return the index of the i that is
all. We're trying to get some intersect collisions working, but the problem experience is
I've got a web app that sends out emails in response to a user-initaited
Is it possible to create a final route that catches all .. and bounces
All, I'm working on a web application for iOS that uses a fixed position
Possible Duplicate: Sending mass email using PHP I have a PHP script that sends
I bounced into a problem when I was trying to create a title on

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.