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

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

      1. <tfoot id='FMpTm'></tfoot>
        • <bdo id='FMpTm'></bdo><ul id='FMpTm'></ul>

        如何在 PHP 中运行 bind_param() 语句?

        时间:2023-07-31
          <tbody id='elIcx'></tbody>

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

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

                • <tfoot id='elIcx'></tfoot>

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

                • 本文介绍了如何在 PHP 中运行 bind_param() 语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使以下代码工作,但无法到达 execute() 行.

                  I'm trying to make the following code work but I can't reach the execute() line.

                  $mysqli = $this->ConnectLowPrivileges();
                  echo 'Connected<br>';
                  $stmt = $mysqli->prepare("SELECT `name`, `lastname` FROM `tblStudents` WHERE `idStudent`=?");
                  echo 'Prepared and binding parameters<br>';
                  $stmt->bind_param('i', 2 );
                  echo 'Ready to execute<br>'
                  if ($stmt->execute()){
                      echo 'Executing..';
                      }
                  } else {
                      echo 'Error executing!';
                  }
                  mysqli_close($mysqli);
                  

                  我得到的输出是:

                  Connected
                  Prepared and binding parameters
                  

                  所以问题应该在第 5 行,但检查 bind_param() 手册我在那里找不到任何语法错误.

                  So the problem should be at line 5, but checking the manual of bind_param() I can't find any syntax error there.

                  推荐答案

                  绑定参数时需要传递一个变量作为引用:

                  When binding parameters you need to pass a variable that is used as a reference:

                  $var = 1;
                  
                  $stmt->bind_param('i', $var);
                  

                  参见手册:http://php.net/manual/en/mysqli-stmt.bind-param.php

                  注意 $var 实际上并不需要定义来绑定它.以下是完全有效的:

                  Note that $var doesn't actually have to be defined to bind it. The following is perfectly valid:

                  $stmt->bind_param('i', $var);
                  
                  foreach ($array as $element)
                  {
                  
                      $var = $element['foo'];
                  
                      $stmt->execute();
                  
                  }
                  

                  这篇关于如何在 PHP 中运行 bind_param() 语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:你如何在 mysqli 准备好的语句中使用 IN 子句 下一篇:mysqli_multi_query 是异步的吗?

                  相关文章

                  最新文章

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

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

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

                    1. <legend id='R8S83'><style id='R8S83'><dir id='R8S83'><q id='R8S83'></q></dir></style></legend>

                      <tfoot id='R8S83'></tfoot>