• <legend id='8cXnh'><style id='8cXnh'><dir id='8cXnh'><q id='8cXnh'></q></dir></style></legend>
    <tfoot id='8cXnh'></tfoot>

      <bdo id='8cXnh'></bdo><ul id='8cXnh'></ul>

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

      <small id='8cXnh'></small><noframes id='8cXnh'>

      1. 错误:mysqli_stmt::bind_param():类型定义字符串中的元

        时间:2023-07-28
      2. <legend id='aXM96'><style id='aXM96'><dir id='aXM96'><q id='aXM96'></q></dir></style></legend>
          <bdo id='aXM96'></bdo><ul id='aXM96'></ul>
              <tbody id='aXM96'></tbody>

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

                <tfoot id='aXM96'></tfoot>

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

                  本文介绍了错误:mysqli_stmt::bind_param():类型定义字符串中的元素数与绑定变量数不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我不确定出了什么问题,一切似乎都很好.

                  I am not sure what is wrong, everything seems to be fine.

                  警告: mysqli_stmt::bind_param():类型定义字符串中的元素数与第 88 行的绑定变量数不匹配

                  Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables on line 88

                  <?php
                  error_reporting(E_ALL); 
                  ini_set('display_errors', 1);
                  
                  include_once 'db_connect.php';
                  include_once 'ex-config.php';
                  
                  
                  
                  $error_msg = "";
                  
                  if (isset($_POST['username'], $_POST['email'], $_POST['p'])) {
                      // Sanitize and validate the data passed in
                      $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
                      $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
                      $email = filter_var($email, FILTER_VALIDATE_EMAIL);
                      if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                          // Not a valid email
                          $error_msg .= '<p class="error">The email address you entered is not valid</p>';
                      }
                  
                      $password = filter_input(INPUT_POST, 'p', FILTER_SANITIZE_STRING);
                      if (strlen($password) != 128) {
                          // The hashed pwd should be 128 characters long.
                          // If it's not, something really odd has happened
                          $error_msg .= '<p class="error">Invalid password configuration.</p>';
                      }
                  
                      // Username validity and password validity have been checked client side.
                      // This should should be adequate as nobody gains any advantage from
                      // breaking these rules.
                      //
                  
                      $prep_stmt = "SELECT id FROM members WHERE email = ? LIMIT 1";
                      $stmt = $mysqli->prepare($prep_stmt);
                  
                     // check existing email  
                      if ($stmt) {
                          $stmt->bind_param('s', $email);
                          $stmt->execute();
                          $stmt->store_result();
                  
                          if ($stmt->num_rows == 1) {
                              // A user with this email address already exists
                              $error_msg .= '<p class="error">A user with this email address already exists.</p>';
                                          $stmt->close();
                          }
                                  $stmt->close();
                      } else {
                          $error_msg .= '<p class="error">Database error Line 39</p>';
                                  $stmt->close();
                      }
                  
                      // check existing username
                      $prep_stmt = "SELECT id FROM members WHERE username = ? LIMIT 1";
                      $stmt = $mysqli->prepare($prep_stmt);
                  
                      if ($stmt) {
                          $stmt->bind_param('s', $username);
                          $stmt->execute();
                          $stmt->store_result();
                  
                                  if ($stmt->num_rows == 1) {
                                          // A user with this username already exists
                                          $error_msg .= '<p class="error">A user with this username already exists</p>';
                                          $stmt->close();
                                  }
                                  $stmt->close();
                          } else {
                                  $error_msg .= '<p class="error">Database error line 55</p>';
                                  $stmt->close();
                          }
                  
                      // TODO: 
                      // We'll also have to account for the situation where the user doesn't have
                      // rights to do registration, by checking what type of user is attempting to
                      // perform the operation.
                  
                      if (empty($error_msg)) {
                  
                          // Create hashed password using the password_hash function.
                          // This function salts it with a random salt and can be verified with
                          // the password_verify function.
                          $password = password_hash($password, PASSWORD_BCRYPT);
                  
                          // Insert the new user into the database 
                          if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, email, password) VALUES (?, ?, ?)")) {
                              $insert_stmt->bind_param('ssss', $username, $email, $password); // THIS IS LINE 88
                              // Execute the prepared query.
                              if (! $insert_stmt->execute()) {
                                  // header('Location: ../error.php?err=Registration failure: INSERT');
                                  // exit;
                                  trigger_error("there was an error....".$mysqli->error, E_USER_WARNING);
                              }
                          }
                          else (header('Location: ../register_success.php'));
                          exit;
                      }
                  }
                  

                  来源:http://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL

                  推荐答案

                  bind_param('ssss', $username, $email, $password); 
                              ^^^^        ^        ^        ^
                              ||||        |        |        |
                          4 parameters    1        2        3          4?
                  

                  4 !== 3

                  这篇关于错误:mysqli_stmt::bind_param():类型定义字符串中的元素数与绑定变量数不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 PHP 上启用 SOAP 下一篇:如何忽略 PHP 中准备好的 mysqli 查询中的参数?

                  相关文章

                  最新文章

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

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

                        <bdo id='iUiMa'></bdo><ul id='iUiMa'></ul>
                      <tfoot id='iUiMa'></tfoot>
                    1. <small id='iUiMa'></small><noframes id='iUiMa'>