Jump to content

Invalid argument supplied for foreach()


timm

Recommended Posts

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:

[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 = '';
        }[/code]

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)?
Link to comment
Share on other sites

[!--quoteo(post=354694:date=Mar 13 2006, 05:31 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 13 2006, 05:31 PM) [snapback]354694[/snapback][/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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.