【发布时间】:2016-06-17 06:38:26
【问题描述】:
我是 PHP 和 SQL 的初学者。我一直在尝试使用以下代码删除 SQL 表中的行,但它不起作用。请帮忙。
<?php
/*
DELETE.PHP
Deletes a specific entry from the 'db' table
*/
// connect to the database
include('connect-db.php');
// check if the 'id' variable is set in URL, and check that it is valid
// get id value
$id = $_GET['id'];
// delete the entry
$result = mysql_query("DELETE FROM db WHERE 'Report No.'= '$id'")
or die(mysql_error());
// redirect back to the view page
header("Location: view.php");
// if id isn't set, or isn't valid, redirect back to view page
{
header("Location: view.php");
}
?>
【问题讨论】:
-
db 是你的表名吗?和报告号??这是什么,这里你需要给你的表字段名称。
-
用引号将列名换成反引号
-
回显删除查询并运行 phpmyadmin SQL 选项卡。执行了吗?
标签: php mysql sql-server