Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    311
    Thanks
    17
    Thanked 0 Times in 0 Posts

    foreach(loop){$query} Trouble

    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 Code:
    <?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
    ?>

  • #2
    New Coder
    Join Date
    Jul 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what exactly are you trying to echo/print?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •