Jump to content

Archived

This topic is now archived and is closed to further replies.

timm

Invalid argument supplied for foreach()

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)?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.