• <small id='P4her'></small><noframes id='P4her'>

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

          <bdo id='P4her'></bdo><ul id='P4her'></ul>
      1. <tfoot id='P4her'></tfoot>
        <legend id='P4her'><style id='P4her'><dir id='P4her'><q id='P4her'></q></dir></style></legend>

        警告:mysqli_query() 需要至少 2 个参数,1 个给定.什

        时间:2023-07-30
        • <tfoot id='Be4SH'></tfoot>
            <tbody id='Be4SH'></tbody>

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

                  <bdo id='Be4SH'></bdo><ul id='Be4SH'></ul>

                • <small id='Be4SH'></small><noframes id='Be4SH'>

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

                  问题描述

                  我制作了一个 PHP 页面,该页面应该从数据库中选择两个名称并显示它们.

                  它只是说:

                  <块引用>

                  警告:mysqli_query() 需要至少 2 个参数,1 个在第 4 行的/home/tdoylex1/public_html/dorkhub/index.php 中给出

                  警告:mysqli_query() 需要至少 2 个参数,1 个在第 8 行的/home/tdoylex1/public_html/dorkhub/index.php 中给出

                  我的代码是:

                  <?php mysqli_connect(localhost,tdoylex1_dork,dorkk,tdoylex1_dork);$name1 = mysqli_query("SELECT name1 FROM users按兰德 () 排序限制 1");$name2 = mysqli_query("SELECT name FROM users按兰德 () 排序限制 1");?><title>DorkHub.在线姓名评级网站.</title><link rel="样式表";类型=文本/css";href=style.css"><body bgcolor='EAEAEA'><中心><div id='标题'><h2>DorkHub.在线名称评级网站.</h2>

                  <p><br><h3><?php echo $name1;?></h3><h4>反对</h4><h3><?php echo $name1;?></h3><br><br><h2 style='font-family:Arial, Helvetica, sans-serif;'>谁的声音最笨?</h2><br><br><div id='投票'><h3 id='done' style='margin-right: 10px'>投票给第一个</h3><h3 id='done'>投票给最后一个</h3>

                  解决方案

                  问题是您没有保存 mysqli 连接.将您的连接更改为:

                  $aVar = mysqli_connect('localhost','tdoylex1_dork','dorkk','tdoylex1_dork');

                  然后将其包含在您的查询中:

                  $query1 = mysqli_query($aVar, "SELECT name1 FROM users按兰德 () 排序限制 1");$aName1 = mysqli_fetch_assoc($query1);$name1 = $aName1['name1'];

                  另外不要忘记将您的连接变量作为字符串括起来,就像我上面所说的那样.这就是导致错误的原因,但您使用的函数错误,mysqli_query 返回一个查询对象,但要从中获取数据,您需要使用类似 mysqli_fetch_assoc http://php.net/manual/en/mysqli-result.fetch-assoc.php 实际获取数据一个变量,我上面有.

                  I made a PHP page that is supposed to select two names from a database and displays them.

                  It just says:

                  Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/tdoylex1/public_html/dorkhub/index.php on line 4

                  Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/tdoylex1/public_html/dorkhub/index.php on line 8

                  My code is:

                  <?php mysqli_connect(localhost,tdoylex1_dork,dorkk,tdoylex1_dork);
                  $name1 = mysqli_query("SELECT name1 FROM users
                  ORDER BY RAND()
                  LIMIT 1");
                  
                  $name2 = mysqli_query("SELECT name FROM users
                  ORDER BY RAND()
                  LIMIT 1");
                  
                  ?>
                  
                  <title>DorkHub. The online name-rating website.</title>
                  <link rel="stylesheet" type="text/css" href="style.css">
                  <body bgcolor='EAEAEA'>
                  <center>
                  <div id='TITLE'>
                      <h2>DorkHub. The online name-rating website.</h2>
                  </div>
                      <p>
                      <br>
                      <h3><?php echo $name1; ?></h3><h4> against </h4><h3><?php echo $name1; ?></h3>
                      <br><br>
                      <h2 style='font-family:Arial, Helvetica, sans-serif;'>Who's sounds the dorkiest?</h2>
                      <br><br>
                      <div id='vote'>
                      <h3 id='done' style='margin-right: 10px'>VOTE FOR FIRST</h3><h3 id='done'>VOTE FOR LAST</h3>
                  

                  解决方案

                  The issue is that you're not saving the mysqli connection. Change your connect to:

                  $aVar = mysqli_connect('localhost','tdoylex1_dork','dorkk','tdoylex1_dork');
                  

                  And then include it in your query:

                  $query1 = mysqli_query($aVar, "SELECT name1 FROM users
                      ORDER BY RAND()
                      LIMIT 1");
                  $aName1 = mysqli_fetch_assoc($query1);
                  $name1 = $aName1['name1'];
                  

                  Also don't forget to enclose your connections variables as strings as I have above. This is what's causing the error but you're using the function wrong, mysqli_query returns a query object but to get the data out of this you need to use something like mysqli_fetch_assoc http://php.net/manual/en/mysqli-result.fetch-assoc.php to actually get the data out into a variable as I have above.

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

                  上一篇:INSERT 查询产生“警告:mysqli_num_rows() 期望参数 1 下一篇:警告问题:期望参数 1 为 mysqli_result

                  相关文章

                  最新文章

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

                  2. <small id='Kpy2v'></small><noframes id='Kpy2v'>

                    <legend id='Kpy2v'><style id='Kpy2v'><dir id='Kpy2v'><q id='Kpy2v'></q></dir></style></legend><tfoot id='Kpy2v'></tfoot>

                      <bdo id='Kpy2v'></bdo><ul id='Kpy2v'></ul>