I have spent a freaking month trying to figure this out, looking on multiple forums, checking documentation, etc. Probably should’ve asked sitepoint a while ago. Basically I get two errors along the lines of:
Couldn't fetch mysqli
and this one:
PHP Fatal error: Uncaught Error: Call to a member function bind_param()
Here’s my HTML form:
<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>
Here’s my PHP code which seems to be creating the fuss:
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');
$stmt = $con->prepare("INSERT INTO posts (title, author, prev_text, img_path, tags, hidden_tags, body, post_date, pad) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_params("sssssssss", $title, $author, $ptext, $imgpath, $tags, $hidden_tags, $body, $post_date, $pad);
$stmt->execute();
$stmt->close();
$con->close();
Could anyone help me out?