这是一个Android应用程序的web服务的代码,这段代码被写入删除用多个参数id和接收器GET方法定义的行,但我总是消息数据库错误。无法删除帖子!什么是解决方案,对不起我的英语不好
<?php
//load and connect to MySQL database stuff
require("config.inc.php");
//initial query
$query = 'DELETE FROM messages WHERE id =? AND receiver =?';
$query_params = array($_GET['id'], $_GET['receiver']);
//execute query
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
$response["success"] = 1;
$response["message"] = "Post Successfully DELETED!";
echo json_encode($response);
}
catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error. Couldn't delete post!";
die(json_encode($response));
}
?>
答案 0 :(得分:2)
您已为语句准备了参数,但实际上从未将它们与语句一起使用。
尝试更改:
$result = $stmt->execute(array());
为:
$result = $stmt->execute($query_params);