<bdo id='rLDCk'></bdo><ul id='rLDCk'></ul>
    1. <legend id='rLDCk'><style id='rLDCk'><dir id='rLDCk'><q id='rLDCk'></q></dir></style></legend>

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

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

      1. 带有 mysqli 的 Bind_param 非对象错误

        时间:2023-07-29
          • <small id='W042s'></small><noframes id='W042s'>

            <legend id='W042s'><style id='W042s'><dir id='W042s'><q id='W042s'></q></dir></style></legend>
                <bdo id='W042s'></bdo><ul id='W042s'></ul>
                  <tbody id='W042s'></tbody>

                  <tfoot id='W042s'></tfoot>
                  <i id='W042s'><tr id='W042s'><dt id='W042s'><q id='W042s'><span id='W042s'><b id='W042s'><form id='W042s'><ins id='W042s'></ins><ul id='W042s'></ul><sub id='W042s'></sub></form><legend id='W042s'></legend><bdo id='W042s'><pre id='W042s'><center id='W042s'></center></pre></bdo></b><th id='W042s'></th></span></q></dt></tr></i><div id='W042s'><tfoot id='W042s'></tfoot><dl id='W042s'><fieldset id='W042s'></fieldset></dl></div>
                1. 本文介绍了带有 mysqli 的 Bind_param 非对象错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  尝试为将跟踪每日视图的表插入初始行时,出现错误:

                  When attempting to insert the initial row for a table that will track daily views, I am getting the error:

                  致命错误:在 157 行/.../functions.php 中的非对象上调用成员函数 bind_param()强>

                  Fatal error: Call to a member function bind_param() on a non-object in /.../functions.php on line 157

                  该行是以下组的最后一行:

                  That line is the last of the following group:

                  if($stats_found) {
                   $sqlquery = "UPDATE vid_stats SET views = ? WHERE title = ? AND format = ? AND date = ? AND results = ?";
                   $views++;
                  } else {
                   $sqlquery = "INSERT INTO vid_stats (views, title, format, results) values (?, ?, ?, ? )";
                   $views = 1;
                  }
                  
                  $stmt = $mysqli->prepare($sqlquery);
                  /* bind parameters for markers */
                  $stmt->bind_param("dsss", $views, $title, $format, "success");
                  

                  关于问题的任何提示?

                  以防万一这是周围代码的问题,这里是完整的功能:

                  Just in case it's an issue with the surrounding code, here is the complete function:

                  function updateViewCount($title, $format, $results) {
                   //update view count
                   global $mysqli;
                   $views = 0;
                   if ($stmt = $mysqli->prepare("SELECT views FROM vid_stats WHERE title = ? AND format = ? AND date = ?")) {
                  
                    /* bind parameters for markers */
                    $stmt->bind_param("ssd", $title, $format, date("Y-m-d"));
                  
                    /* execute query */
                    $stmt->execute();
                  
                    /* bind result variables */
                    $stmt->bind_result($views);
                  
                    /* fetch value */
                    if ($stmt->fetch()) {
                     $stats_found = true;
                    } else { $stats_found = false; }
                  
                    /* close statement */
                    $stmt->close();
                  
                    if($stats_found) {
                     $sqlquery = "UPDATE vid_stats SET views = ? WHERE title = ? AND format = ? AND date = ? AND results = ?";
                     $views++;
                    } else {
                     $sqlquery = "INSERT INTO vid_stats (views, title, format, results) values (?, ?, ?, ? )";
                     $views = 1;
                    }
                  
                    $stmt = $mysqli->prepare($sqlquery);
                    /* bind parameters for markers */
                    echo $sqlquery."<br>".$views."<br>".$title."<br>".$format;
                    $stmt->bind_param("dsss", $views, $title, $format, "success");
                  
                    /* execute query */
                    $stmt->execute();
                  
                    /* close statement */
                    $stmt->close();
                   }
                  }
                  

                  推荐答案

                  问题是用户错误:我把 result 列的名称弄错了.

                  The problem was user error: I had the name of the result column wrong.

                  当我在行 $stmt = $mysqli->prepare($sqlquery); 之后添加 echo $mysqli->error; 时发现了这一点,它显示列名错误.

                  This was uncovered when I added echo $mysqli->error; after the line $stmt = $mysqli->prepare($sqlquery); which revealed the column-name error.

                  这篇关于带有 mysqli 的 Bind_param 非对象错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 MySQLi 连接到多个数据库 下一篇:使用 PHP/MySQLI/Apache 时在哪里安全地存储证书/密钥

                  相关文章

                  最新文章

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

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

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