删除mysql无法在ajax上运行?

cgw*_*b87 0 php mysql

您好我有这个查询...

if (isset($_REQUEST['deletePost'])) {
$q = $dbc -> prepare("DELETE FROM boardposts WHERE postID = ? AND parentID = ?");
$q -> execute(array($_REQUEST['deletePost'], $_REQUEST['deletePost']));
}
Run Code Online (Sandbox Code Playgroud)

我从我的js发出的请求被调用,deletePost并且随身携带的id是正确的.

为什么这会像它一样失败?

我的js看起来像这样

$('.deletePost').click(function() {
    var id = $(this).attr('id');
    $.ajax({
        data: {
            deletePost: id
        },
        success: function() {
            $('.content').empty().html('<p>The selected post and all of its children have been deleted.</p>');
        }
    });
    return false;
});
Run Code Online (Sandbox Code Playgroud)

它返回成功调用,我网站上的所有其他ajax工作正常.ajax的设置在别处定义.

Ken*_*iah 5

因为您的查询看起来不对.不应该WHERE postID = ? OR parentID = ?吗?