繁体   English   中英

PHP使用未定义的常量bigdata

[英]PHP Use of undefined constant bigdata

该代码可以正确处理以下错误:

注意:使用未定义的常量bigdata-在第4行的C:\\ xampp \\ htdocs \\ dynamic_menu \\ index.php中假定为'bigdata'

代码如下:

    //Set the database connection
    ($GLOBALS["___mysqli_ston"] = mysqli_connect('localhost', 'root', 'chethan'));
    ((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . 'bigdata'));
    //select all rows from the main_menu table
    $result = mysqli_query($GLOBALS["___mysqli_ston"], "select id,title,parentid,link from main_menu");

    //create a multidimensional array to hold a list of menu and parent menu
    $menu = array(
        'menus' => array(),
        'parent_menus' => array()
    );

    //build the array lists with data from the menu table
    while ($row = mysqli_fetch_assoc($result)) {
        //creates entry into menus array with current menu id ie. $menus['menus'][1]
        $menu['menus'][$row['id']] = $row;
        //creates entry into parent_menus array. parent_menus array contains a list of all menus with children
        $menu['parent_menus'][$row['parentid']][] = $row['id'];
    }

    // Create the main function to build milti-level menu. It is a recursive function.  
    function buildMenu($parent, $menu) {
    $html = "";
    if (isset($menu['parent_menus'][$parent])) {
        $html .= "<ul>";
        foreach ($menu['parent_menus'][$parent] as $menu_id) {
            if (!isset($menu['parent_menus'][$menu_id])) {
                $html .= "<li><a href='" . $menu['menus'][$menu_id]['link'] . "'>" . $menu['menus'][$menu_id]['title'] . "</a></li>";
            }
            if (isset($menu['parent_menus'][$menu_id])) {
                $html .= "<li><a href='" . $menu['menus'][$menu_id]['link'] . "'>" . $menu['menus'][$menu_id]['title'] . "</a>";
                $html .= buildMenu($menu_id, $menu);
                $html .= "</li>";
            }
        }
        $html .= "</ul>";
    }
    return $html;
}

选择数据库

mysqli_select_db($GLOBALS["___mysqli_ston"], 'bigdata');

对此感兴趣

((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . 'bigdata'));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM