<?php
//Connect to DB
$dbcnx = @mysql_connect("$db_host", $db_user, "$db_password");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
mysql_select_db("daily_audit", $dbcnx);
// Request the text of all the hosts
if(!empty($_POST['checklist'])) {
foreach($_POST['checklist'] as $check) {
$result = mysql_query(
"DELETE FROM hosts_list WHERE IP_Address = %s ", $check);
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
}
}
?>
我在运行以下代码时遇到问题。我已经确认 _POST 变量包含数据,但我很确定我的 SQL 查询的处理方式存在问题。抱歉,我是 PHP n00b,我正在尝试了解如何解决此问题。我知道查询可能需要在 IP 地址周围加上 ' ',这很棘手。提前谢谢大家。