我正在尝试在一个 Mysql 字段上添加 2 个 html 表单字段已尝试此代码,但无法将值插入数据库。
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$city= mysql_real_escape_string($_POST['city']);
$name = mysql_real_escape_string($_POST['name']. "-" . $_POST['domain']);
$alias = mysql_real_escape_string($_POST['alias']);
$date = mysql_real_escape_string($_POST['Date']);
$user = mysql_real_escape_string($_POST['user']);
$id = mysql_real_escape_string($_POST['id']);
$all1 = implode(",",$city);
$all2 = implode(",",$name);
$all3 = implode(",",$alias);
$all4 = implode(",",$date);
$all5 = implode(",",$user);
$all6 = implode(",",$id);
$all1e = explode(",",$city);
$all2e = explode(",",$name);
$all3e = explode(",",$alias);
$all4e = explode(",",$date);
$all5e = explode(",",$user);
$all6e = explode(",",$id);
$insert = mysql_query ("INSERT INTO `Dname` (`city`, `name`, `alias`, `user`, `Date`, `id`) VALUES ('$all1e','$all2e','$all3e','$all4e','$all5e'");
//insert null for id place holder
$insert .= "'')";
$res = mysql_query($insert) or die(mysql_error());
}