...

View Full Version : foreach(loop){$query} Trouble



fuzzy1
03-05-2007, 12:58 AM
Hi All,

Having a bit of trouble. While the following script performs the intended update successfully,
nothing will print or echo after the foreach loop, and I am at a complete loss as to why. Can you help?


<?php # Script test count campaign/contact cycles
require_once ('mysql_connect.php'); // Connect to the db.
mysql_select_db ('crmx') OR DIE ("Could Not select database'crmx':" . MYSQL_ERROR());

$active_contacts = "SELECT contacts.id
FROM contacts, accounts
WHERE contacts.agency_name=accounts.name
AND accounts.active='on'
AND contacts.invalid_email='0'
AND contacts.email_opt_out !='on'
AND contacts.deleted='0' ";
$result = mysql_query ($active_contacts) or die ("Error Retrieving Active Contacts"); // Run the query.
while ($row = mysql_fetch_array($result)) {
$ActiveContacts[] = $row[id];
}
foreach($ActiveContacts as $key =>$value){
//echo 'contact id#' .$value . ' <br>' ;}
$campaigns_per_target = "UPDATE contacts AS a INNER JOIN (
SELECT target_id, count(*) AS count
FROM campaign_log
WHERE campaign_log.target_id = '$value'
GROUP BY campaign_log.target_id
) AS a_c ON a.id = a_c.target_id
SET cycle = count WHERE cycle < count";
$result=@mysql_query($campaigns_per_target) or die ("Query failed Updating Contact Cycles ");
}
// NOTHING WORKS FROM THIS POINT FORWARD... HMMMM????
echo 'SOME TEXT';
echo " some more text";
print "hey you";
// NO SIR-EEE BOB. IT JUST WON'T ECHO OR PRINT
?>

martialtiger
03-05-2007, 02:39 AM
what exactly are you trying to echo/print?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum