timm Posted March 13, 2006 Share Posted March 13, 2006 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 https://forums.phpfreaks.com/topic/4878-invalid-argument-supplied-for-foreach/ Share on other sites More sharing options...
hitman6003 Posted March 13, 2006 Share Posted March 13, 2006 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. Link to comment https://forums.phpfreaks.com/topic/4878-invalid-argument-supplied-for-foreach/#findComment-17176 Share on other sites More sharing options...
timm Posted March 13, 2006 Author Share Posted March 13, 2006 [!--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 https://forums.phpfreaks.com/topic/4878-invalid-argument-supplied-for-foreach/#findComment-17180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.