dsNDesign
Erfahrenes Mitglied
Hi,
ich versuche gerade ein Tutorial nachzumachen. Jedoch kommt bei mir immer ein Fehler.
Es geht um das Tutorial:
http://www.tutorials.de/forum/php-t...namischen-navigation-mit-hilfe-von-mysql.html
Bei mir kommt immer folgender Fehler:
Fatal error: Call to a member function query() on a non-object in /users/designers-place/www/cms/index.php on line 13
line 13 sieht bei mir wiefolgt aus:
Hier mal mein ganzer Code:
Wo liegt mein(e) Fehler? Ich komme einfach nicht drauf.
Grüße
ich versuche gerade ein Tutorial nachzumachen. Jedoch kommt bei mir immer ein Fehler.
Es geht um das Tutorial:
http://www.tutorials.de/forum/php-t...namischen-navigation-mit-hilfe-von-mysql.html
Bei mir kommt immer folgender Fehler:
Fatal error: Call to a member function query() on a non-object in /users/designers-place/www/cms/index.php on line 13
line 13 sieht bei mir wiefolgt aus:
PHP:
$mysql->query("SELECT menu_ID, menu_name FROM menu WHERE menu_topid=0 and `menu_display` != '0' ORDER BY menu_position ASC");
Hier mal mein ganzer Code:
PHP:
<div id="navi">
<?php include_once("db_menu.php");
$mysql->query("SELECT menu_ID, menu_name FROM menu WHERE menu_topid=0 and `menu_display` != '0' ORDER BY menu_position ASC");
$nav_array = array();
$i = 0;
while ($nav_data = $mysql->fetcharray()) {
$nav_array[$i] = array('menu_ID'=>$nav_data["menu_ID"], 'menu_name'=>$nav_data["menu_name"]);
$i++;
}
$nav_id = (int) $_GET["nav_id"];
if ($nav_id <= 0) {
$nav_id = $nav_array[0]['menu_ID'];
}
$mysql->query("SELECT * FROM menu WHERE menu_ID = $nav_id");
$page_data = $mysql->fetcharray();
$page_id = $page_data["menu_page"];
$child_array = array();
$root_array = array();
//Die Stufe beginnt von unten zu zählen, statt von oben. Wird am Schluss umgerechnet
$invlevel = 1;
$mysql->query("SELECT menu_ID, menu_topid, menu_name FROM menu WHERE menu_topid = $nav_id and `menu_display` != '0' ORDER BY menu_position");
$i = 0;
while ($subnav_data = $mysql->fetcharray()) {
$child_array[$i] = array('menu_ID'=>$subnav_data["menu_ID"], 'menu_name'=>$subnav_data["menu_name"], 'menu_topid'=>$subnav_data["menu_topid"], 'level'=>$invlevel);
$i++;
}
//Die nächsthöhere TopID
$next_topid = $page_data["menu_topid"];
//Solange durchlaufen lassen bis obersten Navitationsteile erreicht sind (top_id == 0)
while (($next_topid != 0 || $next_topid != false)) {
if(empty($child_array[0]["menu_topid"])) {
$top_id = $nav_id;
} else {
$top_id = $child_array[0]["menu_topid"];
}
$invlevel++;
$i = 0; //Zähler in der Schlaufe
$mysql->query("SELECT menu_ID, menu_topid, menu_name FROM menu WHERE menu_topid = $next_topid ORDER BY menu_position ASC");
//Die Tabelle auslesen
while($subnav_data = $mysql->fetcharray()) {
$root_array[$i] = array('menu_ID'=>$subnav_data["menu_ID"], 'menu_name'=>$subnav_data["menu_name"], 'menu_topid'=>$subnav_data["menu_topid"], 'level'=>$invlevel);
if($root_array[$i]["menu_ID"] == $top_id) {
$root_array = array_merge($root_array, $child_array);
//Minus 1, weil es sonst einen Zwischenraum gibt. Z.B. $root_array[2], dann $root_array[4]
$i = count($root_array) - 1;
}
$i++;
}
$child_array = $root_array;
$root_array = array();
//Hier wird noch mit der alten $next_topid gerechnet. Die Topid vom höheren Menu wird gelesen
$mysql->query("SELECT menu_topid FROM menu WHERE menu_ID = $next_topid LIMIT 1");
$subnav_data = $mysql->fetcharray();
//Neues $next_topid
$next_topid = $subnav_data["menu_topid"];
}
$anzlevel = $invlevel;
$invlevel = 0;
$number = count($child_array);
//Die Umrechnunsschleife, die Levels werden neu gesetzt: Das Höchste jetzt das Tiefste und umgekehrt
for($i = 0; $i < $number; $i++) {
$invlevel = $child_array[$i]['level'];
$child_array[$i]['level'] = $anzlevel - $invlevel + 1;
}
//Die Subnav_array mit dem vollständigen child_array füllen
$subnav_array = $child_array;
?>
</div>
<div id="content">
<?php include_once("db_content");
$mysql->query("SELECT * FROM content WHERE content_ID = $page_id");
$data = $mysql->fetcharray();
$content_title = $data["content_title"];
$content_text = $data["content_text"];
if ($content_title == "" && $content_text == "") {
$content_title = "JClub-Noch kein Inhalt";
$content_text = "Keine Daten gefunden";
}
?>
</div>
Wo liegt mein(e) Fehler? Ich komme einfach nicht drauf.
Grüße