我的PHP代碼:MySQL錯誤與`對重複KEY UPDATE`
$stmt = $mysqli->prepare("INSERT INTO pages (name, content, in_nav, use_page, page, id) VALUES (?, ?, '$in_nav', '$use_page', ?, '$id'); ON DUPLICATE KEY UPDATE name=?, content=?, in_nav='$in_nav', use_page='$use_page', page=?");
$stmt->bind_param("ssssss", $name, $body, $page, $name, $body, $page);
$stmt->execute();
$stmt->close();
但如果我執行它,它說:
Fatal error: Call to a member function bind_param() on a non-object in C:\xampp\htdocs\cms\admin\cms.php on line 199
當我嘗試$mysqli->error;
它說:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON DUPLICATE KEY UPDATE name=?, content=?, in_nav='1', use_page='0', page=?' at line 1