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>";
}
}
?>