0

I've been trying to fix this error for 2 hours, but no use. Here's my code:

$stmt = $conn->prepare("INSERT INTO posts (post_title, post_content, post_timestamp, post_author, post_intro, link, meta_k, meta_d) VALUES (?,?,?,?,?,?,?,?;");
$stmt->bind_param("ssisssss", $post_title, $post_content, $post_timestamp, $post_author, $post_intro, $link, $meta_k, $meta_d);
$stmt->execute();
Dharman
  • 26,923
  • 21
  • 73
  • 125
Praneeth
  • 79
  • 2
  • 2
  • 10
  • possible duplicate of [Call to a member function bind\_param() on a non-object MySQLi](http://stackoverflow.com/questions/17768200/call-to-a-member-function-bind-param-on-a-non-object-mysqli) – elixenide Jan 10 '15 at 21:01
  • Possible duplicate of [Fatal error: Call to a member function bind\_param() on boolean](http://stackoverflow.com/questions/27394710/fatal-error-call-to-a-member-function-bind-param-on-boolean) – Quentin Aug 17 '16 at 18:25
  • Does this answer your question? [mysqli\_fetch\_assoc() expects parameter / Call to a member function bind\_param() errors. How to get the actual mysql error and fix it?](https://stackoverflow.com/questions/22662488/mysqli-fetch-assoc-expects-parameter-call-to-a-member-function-bind-param) – Dharman Mar 25 '20 at 20:51

2 Answers2

3

This has been answered many times on here. The problem in your instance is that you have a typo in your query:

$stmt = $conn->prepare("INSERT INTO posts (post_title, post_content, post_timestamp, post_author, post_intro, link, meta_k, meta_d) VALUES (?,?,?,?,?,?,?,?;");

should be:

$stmt = $conn->prepare("INSERT INTO posts (post_title, post_content, post_timestamp, post_author, post_intro, link, meta_k, meta_d) VALUES (?,?,?,?,?,?,?,?)");
// typo is at the carat:                                                                                                                                   ^
elixenide
  • 43,445
  • 14
  • 72
  • 97
2

there is an extra ';' in your VALUES()