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

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

        PHP 准备好的语句问题

        时间:2023-07-31

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

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

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

                1. 本文介绍了PHP 准备好的语句问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  慢慢习惯了 PHP 准备好的语句,但仍然出现这个错误

                  slowly getting used to PHP prepared statements, however still get this error

                  警告:mysqli_stmt::bind_result():绑定变量的数量与第 20 行 C:UsersPCDocumentsXAMPPhtdocslogin.php 中准备好的语句中的字段数不匹配".

                  "Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:UsersPCDocumentsXAMPPhtdocslogin.php on line 20".

                   <?php
                  
                   $mysqli = new mysqli('localhost', 'c3337015', 'c3337015', 'members');
                  
                  if (mysqli_connect_errno()) {
                      printf("Connect failed: %s
                  ", mysqli_connect_error());
                      exit();
                      }
                  
                   if(isset($_GET['loginEmail'])){
                  
                   session_start();
                  
                      $stmt = $mysqli->prepare("SELECT Email FROM members WHERE Email=? AND  Password=? LIMIT 1");
                      $email = $_GET['loginEmail'];
                      $password = $_GET['loginPassword'];
                      $password = sha1($password);
                      $stmt->bind_param('ss', $email, $password);
                      $stmt->execute();
                      $stmt->bind_result($email, $password);
                      $stmt->store_result();
                      if($stmt->num_rows == 1)  //To check if the row exists
                          {
                              while($stmt->fetch()) //fetching the contents of the row
                  
                                {$_SESSION['Logged'] = 1;
                                 $_SESSION['Email'] = $email;
                                 header('Location: index.php');
                                 exit();
                                 }
                          }
                          else {
                              echo "Wrong Username or Password!";
                          }
                          $stmt->close();
                      }
                      else 
                      {   
                      echo "Something went Wrong";
                      }
                  $mysqli->close();
                  ?>
                  

                  推荐答案

                  $stmt->bind_result($email, $password);
                  

                  您正在绑定 2 个变量,但只要求一个:SELECT Email FROM members.

                  You are binding 2 variables, but only asking for one: SELECT Email FROM members.

                  我还建议对 bind_result 使用不同的变量,因为它和 bind_param 都适用于引用.

                  I'd also suggest using different variables for bind_result, as it and bind_param both work on references.

                  $stmt->bind_result($userEmail);
                  

                  这篇关于PHP 准备好的语句问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:mysqli_fetch_array 只返回一个结果 下一篇:调用未定义的函数 mysqli_result::num_rows()

                  相关文章

                  最新文章

                  <legend id='c2pbI'><style id='c2pbI'><dir id='c2pbI'><q id='c2pbI'></q></dir></style></legend>

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

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

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