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

时间:2018-06-29 01:56:31

标签: php html mysql

我在HOURS上花费了数小时试图解决此问题,但这对我来说毫无意义。通常,Call to a member function bind_param()表示类似我的语句中缺少变量或表名称缺失。但是事实并非如此,on null如何使其与众不同?另外,如何使用 this 代码解决该问题?

这是我的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

感谢您的有用评论!他们都很感激!

0 个答案:

没有答案