我以网格格式显示了一些数据,现在我试图通过单击最后一行中的删除按钮来删除该行,但出现错误。有人可以告诉我我犯了什么错误。我的代码:
<form action="deleteQuote.php" method="post">
<?php
require_once('config.php');
$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE)
or die ('Cannot connect to db');
$result = $conn->query("SELECT quoteid,name,quote FROM `quotes`, category WHERE category.catid = quotes.catid and quotes.isactive = 1");
echo "<table>";
while ($row = $result->fetch_assoc()) {
echo "<tr><td><input type='hidden' name='delete_id' value=$row[quoteid] /></td> <td>$row[name]</td><td>$row[quote]</td>
<td><input type='submit' value='Delete' /></td></tr>";
}
echo "</table>";
?>
</form>
删除引用.php:
<?php
if(isset($_POST['delete_id']) && !empty($_POST['delete_id'])){
require_once('config.php');
$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE)
or die ('Cannot connect to db');
$delete_id = mysql_real_escape_string($_POST['delete_id']);
echo "DELETE FROM quotes WHERE quoteid =".$delete_id;
$result = $conn->query("DELETE FROM quotes WHERE quoteid =".$delete_id);
}
header('Location: quotes.php');
?>
我收到以下错误:
警告:mysql_real_escape_string() [function.mysql-real-escape-string]: 无法通过 /home/content/38/ 中的套接字 '/var/lib/mysql/mysql.sock' (2) 连接到本地 MySQL 服务器第 6 行的 11053638/html/admin/deleteQuote.php
警告:mysql_real_escape_string() [function.mysql-real-escape-string]:无法在 /home/content/38/11053638/html/ 中建立到服务器的链接第 6 行的 admin/deleteQuote.php 删除引号 WHERE quoteid = 警告:无法修改标头信息 - 标头已由(输出开始于 /home/content/38/11053638/html/admin/deleteQuote.php:6)在 /第 11 行的 home/content/38/11053638/html/admin/deleteQuote.php