我有一个表格可以从我的 sql 数据库中删除一行。我昨天让它正常工作,但由于某种原因,它无法成功删除任何内容,只是返回一条确认消息。我知道我所有的登录/连接详细信息都是正确的。请告诉我这个脚本是否有错误。
PHP
if(isset($_POST['delete']))
{
$dbhost = '';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$address = $_POST['address'];
$sql = "DELETE FROM units WHERE address = '$address'";
mysql_select_db('db_units');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not delete data: ' . mysql_error());
}
echo "Deleted data successfully\n";
mysql_close($conn);
}
else
{
形式
<form method="post" action="<?php $_PHP_SELF ?>">
<td><input name="address" type="text" address="address"></td>
<input name="delete" type="submit" address="delete" value="Delete">