在null上调用成员函数bind_param()

nhhxz33t  于 2021-06-24  发布在  Mysql
关注(0)|答案(0)|浏览(208)

我花了好几个小时试图解决这个问题,但这对我来说毫无意义。一般来说, Call to a member function bind_param() 可能意味着语句中缺少变量,或者缺少表名。但事实并非如此,你怎么知道 on null 让它与众不同?另外,你怎么能用这个代码来解决呢?
以下是我的php:

if (isset($_POST['submit'])) {
              date_default_timezone_set('America/Chicago');
              $title = $_POST['title'];
              $author = $_POST['author'];
              $ptext = $_POST['ptext'];
              $imgpath = $_POST['imagepath'];
              $tags = $_POST['tags'];
              $hidden_tags = $_POST['hidden_tags'];
              $body = $_POST['body'];
              $post_date = date('Y/m/d H:i:s');
              $pad = date('M Y');

          $stmt = $con->prepare("INSERT INTO posts (title, author, prev_text, img_path, tags, hidden_tags, body, post_date, pad) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
          $stmt->bind_param("sssssssss", $title, $author, $ptext, $imgpath, $tags, $hidden_tags, $body, $post_date, $pad);
          echo 'This is a statement test as'.$stmt.'';

              $stmt->execute();
              $stmt->close();
              $con->close();

……这是我的表格:

<form method="post">
           <input type="text" placeholder="Post Title" class="input-box top-margin" name="title" required maxlength="40">
           <br>
           <input type="text" placeholder="Author Name" class="input-box top-margin" name="author" required>
           <br>
           <input type="text" placeholder="Short Preview Text" class="input-box top-margin" name="ptext" required>
           <br>
           <input type="text" class="top-margin input-box top-margin" placeholder="Insert an image path..." name="imagepath" required>
           <br>
           <input type="text" class="top-margin input-box top-margin" placeholder="Enter Tags..." name="tags" required>
           <br>
           <input type="text" class="top margin input-box top-margin" placeholder="Enter Hidden Tags..." name="hidden_tags" required>
           <br>
           <textarea class="input-box top-margin" style="height:150px;" name="body" required></textarea>
           <br>
           <input type="submit" value="Launch Post" class="long-btn btn-def top-margin bottom-margin" name="submit">
        </form>

然而,这还不是全部。我认为这可能与此有关,但我也有一个错误:

PHP Warning:  mysqli::prepare(): Couldn't fetch mysqli in

感谢您的宝贵意见!他们都很感激!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题