Jump to content


Photo

Invalid argument supplied for foreach()


  • Please log in to reply
2 replies to this topic

#1 timm

timm
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 March 2006 - 11:27 PM

I'm hoping to get some help with this, as I cannot figure out what the problem may be. I've installed a script which was in spanish, so, I've had to sorta figure out the installation on my own. Finally, seemed to be done when the page put this out when trying to display the categories:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: Invalid argument supplied for foreach() in xxx on line 332[/quote]

Now, here is code:

// draw categories
    foreach ($categories as $category) {

        if($category->category_id == $what_cat_id) {
            $globals['category_id'] = $category->category_id;
            $globals['category_name'] = $category->category_name;
            $thiscat = ' class="thiscat"';
        }
        else {
            $thiscat = '';
        }

It does not appear to be a problem with the MySQL. Could this have something to do with the PHP version and if so, how would I go about replacing it (the code, not the a php update)?

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 13 March 2006 - 11:31 PM

According to the error, the variable $categories, is not an array. If you are creating that array from a mysql query, then it probably is your query.

#3 timm

timm
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 March 2006 - 11:38 PM

[!--quoteo(post=354694:date=Mar 13 2006, 05:31 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 13 2006, 05:31 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
According to the error, the variable $categories, is not an array. If you are creating that array from a mysql query, then it probably is your query.
[/quote]

You were right, it was the query. It seems that I forgot to change the 'lang' to 'en', simple enough - works great now.

Thank you.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users