<bdo id='y4S8G'></bdo><ul id='y4S8G'></ul>
<legend id='y4S8G'><style id='y4S8G'><dir id='y4S8G'><q id='y4S8G'></q></dir></style></legend>

  1. <small id='y4S8G'></small><noframes id='y4S8G'>

    <tfoot id='y4S8G'></tfoot>

      <i id='y4S8G'><tr id='y4S8G'><dt id='y4S8G'><q id='y4S8G'><span id='y4S8G'><b id='y4S8G'><form id='y4S8G'><ins id='y4S8G'></ins><ul id='y4S8G'></ul><sub id='y4S8G'></sub></form><legend id='y4S8G'></legend><bdo id='y4S8G'><pre id='y4S8G'><center id='y4S8G'></center></pre></bdo></b><th id='y4S8G'></th></span></q></dt></tr></i><div id='y4S8G'><tfoot id='y4S8G'></tfoot><dl id='y4S8G'><fieldset id='y4S8G'></fieldset></dl></div>

      警告:mysqli_error() 需要 1 个参数,0 给定错误

      时间:2023-07-31

            <bdo id='gmZQB'></bdo><ul id='gmZQB'></ul>
              <tbody id='gmZQB'></tbody>
              <tfoot id='gmZQB'></tfoot>
            • <i id='gmZQB'><tr id='gmZQB'><dt id='gmZQB'><q id='gmZQB'><span id='gmZQB'><b id='gmZQB'><form id='gmZQB'><ins id='gmZQB'></ins><ul id='gmZQB'></ul><sub id='gmZQB'></sub></form><legend id='gmZQB'></legend><bdo id='gmZQB'><pre id='gmZQB'><center id='gmZQB'></center></pre></bdo></b><th id='gmZQB'></th></span></q></dt></tr></i><div id='gmZQB'><tfoot id='gmZQB'></tfoot><dl id='gmZQB'><fieldset id='gmZQB'></fieldset></dl></div>

                <legend id='gmZQB'><style id='gmZQB'><dir id='gmZQB'><q id='gmZQB'></q></dir></style></legend>
              1. <small id='gmZQB'></small><noframes id='gmZQB'>

                本文介绍了警告:mysqli_error() 需要 1 个参数,0 给定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我收到以下错误

                <块引用>

                警告:mysqli_error() 需要 1 个参数,0 给定

                问题在于这行代码:

                $query = mysqli_query($myConnection, $sqlCommand) 要么死 (mysqli_error());

                整个代码是

                session_start();require_once "scripts/connect_to_mysql2.php";//构建主导航菜单并在此处收集页面数据$sqlCommand = "SELECT id, linklabel FROM pages ORDER BY pageorder ASC";$query = mysqli_query($myConnection, $sqlCommand) 要么死 (mysqli_error());$menuDisplay = '';而 ($row = mysqli_fetch_array($query)) {$pid = $row["id"];$linklabel = $row["linklabel"];$menuDisplay .= '<a href="index.php?pid='. $pid .'">'.$链接标签.'</a><br/>';}mysqli_free_result($query);

                包含的文件有以下一行

                $myConnection = mysqli_connect("$db_host","$db_username","$db_pass","$db_name") 要么死("无法连接到mysql");参考 $myConnection,为什么会出现此错误?

                解决方案

                mysqli_error() 需要你将连接作为参数传递给数据库.此处的文档提供了一些有用的示例:

                http://php.net/manual/en/mysqli.error.php

                试着像这样改变你的问题线,你应该处于良好的状态:

                $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error($myConnection));

                I get the following error

                Warning: mysqli_error() expects exactly 1 parameter, 0 given

                The problem is with this line of the code:

                $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
                

                The whole code is

                session_start();
                
                require_once "scripts/connect_to_mysql2.php";
                
                //Build Main Navigation menu and gather page data here
                
                $sqlCommand = "SELECT id, linklabel FROM pages ORDER BY pageorder ASC";
                
                $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
                
                $menuDisplay = '';
                while ($row = mysqli_fetch_array($query)) { 
                    $pid = $row["id"];
                    $linklabel = $row["linklabel"];
                
                    $menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a><br />';
                
                } 
                mysqli_free_result($query); 
                

                The included file has the following line

                $myConnection = mysqli_connect("$db_host","$db_username","$db_pass","$db_name") or die ("could not connect to mysql"); with reference to $myConnection, why do I get this error?
                

                解决方案

                mysqli_error() needs you to pass the connection to the database as a parameter. Documentation here has some helpful examples:

                http://php.net/manual/en/mysqli.error.php

                Try altering your problem line like so and you should be in good shape:

                $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error($myConnection)); 
                

                这篇关于警告:mysqli_error() 需要 1 个参数,0 给定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:带有动态参数的动态选择 mysqli 查询返回错误与绑 下一篇:mysqli忽略表中的第一行

                相关文章

                最新文章

                  • <bdo id='MxVUM'></bdo><ul id='MxVUM'></ul>

                  <small id='MxVUM'></small><noframes id='MxVUM'>

                  <legend id='MxVUM'><style id='MxVUM'><dir id='MxVUM'><q id='MxVUM'></q></dir></style></legend>
                  <i id='MxVUM'><tr id='MxVUM'><dt id='MxVUM'><q id='MxVUM'><span id='MxVUM'><b id='MxVUM'><form id='MxVUM'><ins id='MxVUM'></ins><ul id='MxVUM'></ul><sub id='MxVUM'></sub></form><legend id='MxVUM'></legend><bdo id='MxVUM'><pre id='MxVUM'><center id='MxVUM'></center></pre></bdo></b><th id='MxVUM'></th></span></q></dt></tr></i><div id='MxVUM'><tfoot id='MxVUM'></tfoot><dl id='MxVUM'><fieldset id='MxVUM'></fieldset></dl></div>
                  1. <tfoot id='MxVUM'></tfoot>