該頁面將刪除帖子:未定義功能在MySQL和PHP
require_once ('db.php');
$db = new DB();
$db->deletePost($_GET['id'], $_GET['postType']);
db.php中只包含一類稱爲DB和它的功能。
這是db.php中的一部分:
public function deleteComment($post_id, $post_type)
{
$query = "delete from t_comments where c_type = '$post_type' and c_id = '$post_id';";
$this->execute($query);
}
public function deletePost($post_id, $post_type)
{
deleteComment($post_id, $post_type);
$query = "delete from t_news where n_id = '$post_id';";
$this->execute($query);
}
那麼MySQL說: 致命錯誤:調用未定義的函數deletecomment()在db.php中上線70
我定義deleteComment以上deletePost!那麼是什麼問題?我不能在該類中調用另一個類的函數嗎?但是在C++中,我認爲這是可能的!
旁註:你更好的'SQL讀了injection' – bububaba 2012-01-12 12:16:55
另一個側面說明,沒有爲自己的數據庫中使用'GET'操作;它可能會導致搜索引擎或瀏覽器加速器清除數據庫。 – jeroen 2012-01-12 12:20:45