<?php
$id = $_POST['dr'];
$dbhost = 'star***.***.edu';
$dbuser = '***4123';
$dbpass = '*****';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn)
{
die('Could not connect: ' . mysql_error());
}
$sql = "DELETE FROM address
WHERE idnum=\"".$id\"";
mysql_select_db('***4123');
$retval = mysql_query($sql, $conn);
if(! $retval)
{
die('Could not delete data: ' . mysql_error());
}
echo "Deleted data successfully\n";
mysql_close($conn);
?>
所以,只需要一些幫助,找出這是否是句法上正確的。應通過ajax發送的是我希望在表地址中刪除的行的編號這是這個mysql/php正確刪除一行嗎?
它容易受到[SQL注入](http://en.wikipedia.org/wiki/SQL_injection)的影響。使用類似'intval()'或'is_int'來確保參數是一個數字 – 2011-05-08 19:18:42