at line 317, it sets the CHILD ID column, it was using a column name that does not exist in the undergrupper table:
echo "WAJA[".$n."][".$m."][0] = "."'".WA_DD_Replace($row_WADAMenuUnderkategori["id"])."'".";\n";
I changed that to:
echo "WAJA[".$n."][".$m."][0] = "."'".WA_DD_Replace($row_WADAMenuUnderkategori["Gruppeid"])."'".";\n";
to correct the problem.