简体   繁体   中英

Call to a member function bind_param() on boolean

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();

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:                                                                                                                                   ^

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM