Here's the bug I encountered when coding for my client and took me an hour to figure out the cause.
if (db_affected_rows($result2) > 0) {
$m = 0;
while ($row2 = db_fetch_array($result2)) {
print ‘—-dang o node con so ‘ . $m . ‘ ten la ‘ . $row2['title'] . ‘<br />’;
$menu_overview3[$m]["class"] = ‘menu’;
$menu_overview3[$m]["href"] = ‘node/’ . $row2['nid'];
$menu_overview3[$m]["title"] = $row2['title'];
$m++;
}
$menu_overview2[$n]["sub"] = $menu_overview3;
unset($menu_overview3);
$menu_overview2[$n]["subclass"] = ‘menu-overview3′;
}
$n++;If you dont have the line:
unset($menu_overview3);the code will still use $menu_overview3 for the next loop, so for example, if this variable currently have 4 elements such as a, b, c, d and after that you fill it with e, f, it will actually contain e, f, c, d instead of e, f.

0 comments:
Post a Comment