【问题标题】:PHP Use of undefined constant bigdataPHP使用未定义的常量大数据
【发布时间】:2016-11-13 03:35:47
【问题描述】:

代码在错误中正常工作:

注意:使用未定义的常量大数据 - 在 C:\xampp\htdocs\dynamic_menu\index.php 第 4 行

代码如下:

    //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'));
  • mysqli_query($GLOBALS["___mysqli_ston"], "USE " . "bigdata");
  • 兄弟.. 成功了.. 谢谢赞赏!
  • 第一个评论或第二个评论哪个对您有用?
  • 用绿色勾号回答它对未来用户有用

标签: php mysqli-multi-query


【解决方案1】:

像这样选择数据库

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

这个

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

【讨论】:

    猜你喜欢
    • 2016-08-19
    • 1970-01-01
    • 2020-03-16
    • 1970-01-01
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多