<bdo id='3Kl5A'></bdo><ul id='3Kl5A'></ul>

    <small id='3Kl5A'></small><noframes id='3Kl5A'>

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

        Php mysqi bind_param 变量数与准备好的语句中的参数

        时间:2023-07-31
      2. <tfoot id='N9vwc'></tfoot>
      3. <i id='N9vwc'><tr id='N9vwc'><dt id='N9vwc'><q id='N9vwc'><span id='N9vwc'><b id='N9vwc'><form id='N9vwc'><ins id='N9vwc'></ins><ul id='N9vwc'></ul><sub id='N9vwc'></sub></form><legend id='N9vwc'></legend><bdo id='N9vwc'><pre id='N9vwc'><center id='N9vwc'></center></pre></bdo></b><th id='N9vwc'></th></span></q></dt></tr></i><div id='N9vwc'><tfoot id='N9vwc'></tfoot><dl id='N9vwc'><fieldset id='N9vwc'></fieldset></dl></div>
            <tbody id='N9vwc'></tbody>

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

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

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

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

                  问题描述

                  这一定是新手的错误,但我没有看到.这是我的代码片段:

                  This has to be a newbie mistake, but I'm not seeing it. Here is a snippet from my code:

                  $mysqli = mysqli_connect($dbCredentials['hostname'], 
                      $dbCredentials['username'], $dbCredentials['password'], 
                      $dbCredentials['database']);
                  
                  if ($mysqli->connect_error) {
                      throw new exception( 'Connect Error (' . $mysqli->connect_errno . ') '
                      . $mysqli->connect_error);
                  }
                  
                  $stmt = $mysqli->prepare("SELECT DISTINCT model FROM vehicle_types 
                      WHERE year = ? AND make = '?' ORDER by model");
                  
                  $stmt->bind_param('is', $year, $make);
                  
                  $stmt->execute();
                  

                  当我回显 $year 和 $make 的值时,我看到的是值,但是当我运行这个脚本时,我得到一个空值,并且我的日志文件中出现以下警告:

                  When I echo out the values for $year and $make, I am seeing values, but when I run this script, I get a null value, and the following warning appears in my log file:

                  PHP Warning:  mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
                  

                  在这种情况下,year 在数据库中的类型为 int(10),我尝试传递一个已转换为 int 的副本,而 make 是使用 utf8_unicode_ci 编码的 varchar(20).我错过了什么吗?

                  In this case, year is in the database in type int(10), and I have tried passing a copy that had been cast as an int, and make is a varchar(20) with the utf8_unicode_ci encoding. Am I missing something?

                  推荐答案

                  你准备好的语句有误,应该是:

                  Your prepared statement is wrong, it should be:

                  $stmt = $mysqli->prepare("SELECT DISTINCT model FROM vehicle_types WHERE year = ? AND make = ? ORDER by model");
                  

                  单引号使?是价值而不是标记.它已经是一个字符串,因为您正在使用 bind_param('is'

                  The single quotes made that ? be the value not a marker. It will already be a string because you are casting as such with bind_param('is'

                  这篇关于Php mysqi bind_param 变量数与准备好的语句中的参数数不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何计算查询结果行数? 下一篇:MySQLI 使用 call_user_func_array 绑定参数

                  相关文章

                  最新文章

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

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

                    1. <tfoot id='WZzcx'></tfoot>

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