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

    • <bdo id='PlhTH'></bdo><ul id='PlhTH'></ul>
    <legend id='PlhTH'><style id='PlhTH'><dir id='PlhTH'><q id='PlhTH'></q></dir></style></legend>

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

        mysqli_real_escape_string() 期望参数 1 是 mysqli,布尔值

        时间:2023-09-24

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

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

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

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

                • 本文介绍了mysqli_real_escape_string() 期望参数 1 是 mysqli,布尔值给定集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我收到很多错误,例如:mysqli_real_escape_string() 期望参数 1 为 mysqli,给出布尔值

                  I get a lot of errors like: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given

                  错误是 mysqli_real_escape_string() 需要 2 个参数,但只有 1 个项目需要更新.

                  The errors are that the mysqli_real_escape_string() expects 2 parameters but there is only 1 item that needs to be updated.

                  问题出在这里:

                  $updatequery = "
                      UPDATE
                          as_comprofiler
                      SET
                          cb_empstatustime = '".time()."'
                          , cb_profiel = '".mysqli_real_escape_string($value->profile->nickname)."'
                          , cb_empstatus = '".mysqli_real_escape_string($cb_empstatus)."'
                          , cb_taal = '".mysqli_real_escape_string($talen)."'
                          , cb_sms = '".mysqli_real_escape_string($sms)."'
                      WHERE
                          cb_boxnr = '".mysqli_real_escape_string($value->boxnumber)."'
                      "; 
                  

                  以及页面的完整部分:

                  // elke ***
                  foreach ($xml->consultant as $value) {
                  
                      // $cb_empstatus vullen a.d.h.v activated en callstatus
                      if ($value->activated == 0) {
                          $cb_empstatus = 'Afwezig';
                      } elseif ($value->activated == 1) {
                          if ($value->callstatus == 0) {
                              $cb_empstatus = 'Beschikbaar';
                          } elseif ($value->callstatus == 1) {
                              $cb_empstatus = 'Bezet';
                          } elseif ($value->callstatus == 2) {
                              $cb_empstatus = 'Pauze';
                          }
                      }
                  
                      // lege variabele aanmaken
                      $talen = '';
                      $sep = '';
                  
                      foreach ($value->languages->language as $taal) {
                          $talen .= $sep;
                          $talen .= $taal;
                          $sep = '|*|';
                      }
                  
                      // sms code omzetten naar tekst
                      if ($value->smsavailable == 1) {
                          $sms = 'Ja';
                      } else {
                          $sms = 'Nee';
                      }
                  
                      // de update query
                      $updatequery = "
                          UPDATE
                              as_comprofiler
                          SET
                              cb_empstatustime = '".time()."'
                              , cb_profiel = '".mysqli_real_escape_string($value->profile->nickname)."'
                              , cb_empstatus = '".mysqli_real_escape_string($cb_empstatus)."'
                              , cb_taal = '".mysqli_real_escape_string($talen)."'
                              , cb_sms = '".mysqli_real_escape_string($sms)."'
                          WHERE
                              cb_boxnr = '".mysqli_real_escape_string($value->boxnumber)."'
                          ";
                  
                      if (mysqli_query($updatequery) == false) {
                          // foutmelding
                          echo 'Niet uitgevoerd:<br>'.$updatequery.'<br><br>';
                      }
                  

                  有人有想法吗?

                  推荐答案

                  你必须添加 mysqli 连接器 作为 mysqli_real_escape_string() 函数中的第一个参数.并且要转义的字符串设置为第二个参数.

                  You have to add mysqli connector as 1st parameter in mysqli_real_escape_string() function. And the string to be escaped set as 2nd parameter.

                  <?php
                  // Let's suppose this is your mysqli connector
                  $mysqli = mysqli_connect("localhost", "user", "password", "database");
                  
                  // Then your code should looks like this:
                  $updatequery = "
                      UPDATE
                          as_comprofiler
                      SET
                          cb_empstatustime = '".time()."'
                          , cb_profiel = '".mysqli_real_escape_string($mysqli, $value->profile->nickname)."'
                          , cb_empstatus = '".mysqli_real_escape_string($mysqli, $cb_empstatus)."'
                          , cb_taal = '".mysqli_real_escape_string($mysqli, $talen)."'
                          , cb_sms = '".mysqli_real_escape_string($mysqli, $sms)."'
                      WHERE
                          cb_boxnr = '".mysqli_real_escape_string($mysqli, $value->boxnumber)."'
                      "; 
                  ?>
                  

                  mysqli_real_escape_string 的文档说得很清楚:

                  mysqli_real_escape_string(mysqli $mysql, string $string): string

                  这意味着:

                  1. 第一个参数必须是 mysqli 对象,由 mysqli_connect() 或 mysqli_init()
                  2. 第二个参数必须是要转义的字符串.

                  这篇关于mysqli_real_escape_string() 期望参数 1 是 mysqli,布尔值给定集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Mysqli 不允许多个查询? 下一篇:未定义索引:___mysqli_ston

                  相关文章

                  最新文章

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

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

                    1. <small id='lMNX7'></small><noframes id='lMNX7'>

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