您好,我对此没什么问题:
require_once("dbconnect.php");
mysql_query('set names utf8');
$query = ('DELETE FROM `gallery` WHERE `id` = 16') or die("failed");
它不会从DB中删除记录。你能帮助我吗?谢谢。 dbconnect.php是正确的。
答案 0 :(得分:2)
您所做的只是声明变量$query
,但您没有运行它。您必须运行$query = mysql_query('DELETE FROM `gallery` WHERE `id` = 16')
编辑:话虽如此,请勿使用mysql_
个功能。它们允许SQL注入,这非常危险。相反,最好使用
$mysqli = new mysqli(HOST, USERNAME, PASSWORD, DATABASE);
$query = $mysqli->query('DELETE FROM `gallery` WHERE `id` = 16');