当我尝试在我的项目中实现代码时出现错误。
我的代码:
//In file with class 'Article'.
public function deleteArticle($id) {
$conn = $this->connect();
$sql = "UPDATE article SET deleted=1 WHERE row_id=?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
return $result;
}
//In file with class 'DBConn'.
public function connect() {
$conn = new mysqli('localhost', 'root', '','nicms');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
return $conn;
}
//In file with class 'articleContr'.
public function showDeleteArticle($id) {
if ($this->deleteArticle($id)
echo "Article has successfully been deleted.";
else
echo "Failed to delete article.";
}
错误是文章确实被删除了,但是 showDeleteArticle 方法给出了消息“无法删除文章”。尽管文章已被删除。
犯罪嫌疑人X
慕标5832272