Hey All,
Only a little research quickly reveals that this is a common stumbling block for many.
A good deal more research has yet to reveal the root of my problem (inexperience not withstanding=).
table 'contacts_emails'
id varchar(36) latin1_swedish_ci No
email_id varchar(36) latin1_swedish_ci Yes NULL
contact_id varchar(36) latin1_swedish_ci Yes NULL
date_modified datetime Yes NULL
deleted tinyint(1) No 0
(I count 5 - id, email_id, contact_id,date_modified,deleted)
script:
$bounced_auto_respond = "SELECT emails.id AS e_id, contacts.id AS c_id
FROM emails, contacts
WHERE emails.intent = 'bounce'
AND emails.id NOT IN(SELECT email_id FROM emails_contacts)
AND emails.from_addr = contacts.email1
AND emails.from_name !=emails.reply_to_name";
$result = @mysql_query ($bounced_auto_respond)or die ("Select Query failed " .mysql_error());
$numrows=mysql_num_rows($result);
if ($numrows == 0)
{return;}
else {
// convert results $bounced_auto_respond to array
while ($row = mysql_fetch_assoc($result)) {
$date_modified = date("Y-m-d H:i:s");
$key = uniqid(rand(), true);
$ar_bounced[] = "('$key','$row[e_id]','$row[c_id]','$date_modified','0')";
}
}
foreach ($ar_bounced as $key => $value) {
echo $value ."<br>";
$result=@mysql_query("INSERT INTO emails_contacts(id,email_id,contact_id,date_modified,deleted)
VALUES($value)")
or die ("Insert Query Failed " .mysql_error()); // Run the query. $affected_rows = mysql_affected_rows ();
}
echoed $value returns what appear to be appropriate values (5 of them) but still the error.
Curious though that only one result set is echoed, while the select query returns 5. (not to be confused with the 5 columns in question) Would think echo $value would also return five result/insert sets? (foreach???)
Please, what am I missing here?