$sql = "SELECT post_title, post_body, post_author FROM forum_post WHERE post_id='".$pid."' forum_id='".$id."' AND post_type='o'";
if($topicPost = $mysql->prepare($sql)) {
$topicPost->bind_param('ss',$pid,$id);
$topicPost->bind_result($post_title, $post_body, $post_author);
$topicPost->execute();
$topicPost->store_result();
} else {
echo "ErrorinSQLLL, ".$mysql->error;
exit();
}
因此,有我的SQL查询语句。
我得到这个印在我的网页:
ErrorinSQLLL,你有一个错误的SQL语法;检查对应于你的MySQL服务器版本使用附近的正确语法手册第1行
如果需要,我可以发布更多的我的代码“forum_id =” 1“”。
你会错过的,在这里 “POST_ID = '$ PID' AND forum_id = '$ ID'” – jarlh 2015-02-11 10:40:57
'WHERE POST_ID = '$ PID' forum_id = '$ id'',然后尝试绑定'$ pid'和'$ id'以及......但是在SQL中没有占位符将它们绑定在一起......看起来好像你对绑定有根本性的误解使你的SQL不安全的变量.....你的SQL应该是WHERE post_id =? AND forum_id =?' – 2015-02-11 10:43:00