2
這是一個android應用程序的webservice的代碼,這個代碼組的代碼被寫入刪除行,定義了多個參數id和接收方GET方法,但我總是有消息Database Error 。無法刪除帖子!有什麼解決方案,請對不起我的英語不好在PHP和MySQL中準備好的查詢刪除行
<?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));
}
?>
嘗試增加'$ EX->的getMessage()'你失敗的消息。那應該告訴你出了什麼問題。 – 2014-10-08 02:47:36
你沒有用'$ query_params'做任何事情 – 2014-10-08 02:48:21
@MikeW這應該讀作'$ ex-> getMessage()';) – 2014-10-08 02:50:30