Warning: Invalid argument supplied for foreach() with yahoo

Discussion in 'Keyword Tracker' started by Kim Steinhaug, Sep 9, 2005.

  1. #1
    When doing keyword checks for Yahoo Im getting theese errors, and they dont show up on all keywords either... hmmm...

    The error message is, and only on Yahoo on certain keywords :

    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>/.../advanced.script.php</b> on line <b>163</b><br />
    Code (markup):
    I couldnt seem to find any threads that explains what is happening. Then again I havnt looked to much into the accual script either to understand the code.
     
    Kim Steinhaug, Sep 9, 2005 IP
  2. Kim Steinhaug

    Kim Steinhaug Peon

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    For the moment I just added an extra validation around the foreach() statement, to atleast ignore the error.

    [B]if(is_array($index['URL'])){
    [/B]    foreach ($index['URL'] as $url_key) {
         if ($vals[$url_key]['level'] == 3) {
          if (substr_count (strtolower ($vals[$url_key]['value']), $_REQUEST['u'])) $results[] = $position;
    
          if ($_REQUEST['s']) {
           $results_detail[$position]['title'] = $vals[$url_key - 2]['value'];
           $results_detail[$position]['summary'] = $vals[$url_key - 1]['value'];
           $results_detail[$position]['url'] = $vals[$url_key]['value'];
          }
          $position++;
         }
        }
    [B]}[/B]
    PHP:
     
    Kim Steinhaug, Sep 9, 2005 IP