News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Invalid argument supplied for foreach()

Started by SikLiFe, February 28, 2010, 04:44:09 PM

Previous topic - Next topic

SikLiFe

2: Invalid argument supplied for foreach()
File: /home/*******/public_html/forum/Sources/Subs.php
Line: 4247


i have a full error log with that,


heres the code included around that line;

// begin "Menu Order" edit //
if (!empty($modSettings['menuorder'])) {
$menuorder = unserialize($modSettings['menuorder']);
$newmenu = array();
foreach($menuorder as $key => $value) {
if (isset($context['menu_buttons'][$key]) && $context['menu_buttons'][$key]['show'] == true) {
$newmenu[$key] = $context['menu_buttons'][$key];
}
}
foreach($context['menu_buttons'] as $key => $value) {
if (!array_search($key, $newmenu)) {
$newmenu[$key] = $value;
}
}
$context['menu_buttons'] = $newmenu;
}
if (!empty($modSettings['menuorder_titles'])) {
$menutitles = unserialize($modSettings['menuorder_titles']);
foreach($menutitles as $key => $value) {
if (isset($context['menu_buttons'][$key]['title']) && $value != '_no_change_') {
$context['menu_buttons'][$key]['title'] = $value;
$context['menu_buttons'][$key]['no_change'] = false;
} else if ($value == '_no_change_') {
$context['menu_buttons'][$key]['no_change'] = true;
} else {
$context['menu_buttons'][$key]['no_change'] = false;
}
}
}
if (!empty($modSettings['menuorder_visible'])) {
$menuorder_visible = unserialize($modSettings['menuorder_visible']);
if (empty($_GET['action']) || $_GET['action'] != 'admin') {
foreach($menuorder_visible as $key => $value) {
if ($value == false) {
unset($context['menu_buttons'][$key]);
}
}
}
} else {
$menuorder_visible = array();
foreach($menutitles as $key => $value) {
$menuorder_visible[$key] = true;
}
}
$context['menuorder_visible'] = $menuorder_visible;

foreach($context['menu_buttons'] as $key => $button) {
$context['menuorder_show'][$key] = true;
}
// end "Menu Order" edit //



and this line seems to be number 4247 i believe,,

} else {


right before

$menuorder_visible = array();
foreach($menutitles as $key => $value) {
$menuorder_visible[$key] = true;}
A great breakfast is always the right answer.

SikLiFe

I also get alot of Errors like this


8: Undefined variable: menutitles
?topic=389.0


if anyone has an idea, it'd be appreciated thanks!! =]
A great breakfast is always the right answer.

Oldiesmann

The $menutitles variable isn't defined, and that in turn is causing the "invalid argument supplied for foreach()" errors. What mods do you have installed? I don't think $menutitles exists in a default SMF installation.
Michael Eshom
Christian Metal Fans

SikLiFe

I'd only think it'd have to do with menu order since that allows me to place the order of my menu items, either way,
it's been a pain, hasn't affected anything on my forum except a huge massive error log.


1.  RSS Feed Poster  2.1   
2. Redirect Links 1.0.2
3. Proxy Blocker 1.1.4
4. Member Color Link 3.0.8
5. Mark_Reader_Name
6. Add Honey Pot to Track IP
7. cb|Emailogin 0.3
8. YouTube BBCode 2.5.1
9. Profile Song Player 1.0 Beta
10. Downloads System 1.2.7
11. SMF Arcade 2.5 RC1
12. Menu Order 0.2.1
13. Board Notices 1.0
14. Redirection Topics 1.0
15. BetterPHP 1.0
16. Reflection Avatar 1.1
17. EzPortal 0.3.6
A great breakfast is always the right answer.

Oldiesmann

It's definitely related to the Menu Order mod, since the first block of code you posted has "// begin "Menu Order" edit //" above it.

It looks like this occurs when $modSettings['menuorder_titles'] is empty.

The foreach($menutitles ...) code is always called if $modSettings['menuorder_visible'] is empty, but $menutitles isn't set if $modSettings['menuorder_titles'] is empty.

I would suggest contacting the mod author for help. As I've never used the mod, it's hard to say how you could fix the problem (besides uninstalling the mod).
Michael Eshom
Christian Metal Fans

SikLiFe

#5
Infact you were right, same as this person
http://www.simplemachines.org/community/index.php?topic=364747.0
i've uninstalled the mod and it no longer gives me errors,  was a good mod to despite the error.

I'll continue to leave this thread un-solved as maybe someone might come up with an idea to fix that portion,
A great breakfast is always the right answer.

Advertisement: