Re: problem with for loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nathan Nobbe wrote:
On Fri, May 2, 2008 at 1:20 AM, Richard Kurth <richardkurth@xxxxxxxxxxxxxx <mailto:richardkurth@xxxxxxxxxxxxxx>> wrote:

    Way does my for loop not complete the task if there are 4 emails
    it only process 3 emails through the foreach loop if there is 3 it
    only process 2

    $file=file_get_contents("C:\web\bouncehandler\eml\em$i");
    $multiArray = Bouncehandler::get_the_facts($file);


have you checked $multiArray here to verify it has the number of emails you expect there are to be processed ?

    $EMAIL = $the['recipient'];
    foreach($multiArray as $the){
          switch($the['action']){
          case 'failed':
          $sql="UPDATE contacts SET emailstatus = 'Fatal-Bounced'
    WHERE emailaddress = '$EMAIL'";
          mysql_query($sql) or die("Invalid query: " . mysql_error());
              break;
          case 'transient':
          $sql="UPDATE contacts SET emailstatus = 'Bounced' WHERE
    emailaddress = '$EMAIL'";
          mysql_query($sql) or die("Invalid query: " . mysql_error());
          break;
          case 'autoreply':
          $sql="UPDATE contacts SET emailstatus = 'Bounced' WHERE
    emailaddress = '$EMAIL'";
          mysql_query($sql) or die("Invalid query: " . mysql_error());
          break;
          default:
          //don't do anything
          break;
          }


have you done any logging, or error checking to see if one (or more) of the emails isnt falling into the default case of the switch statement ?
-nathan

Yes I have it is just no processing the last email. I have even printed them out before the foreach and it always comes out one less that there are emails. It is downloading the correct amount and creating them in the directory it is just not passing the last one on


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux