我遇到了这个问题。我正在努力使这些字段组合起来,一个用 - 而一个没有插入数据库
$daters = $_POST['11']." ". $_POST['22']." ". $_POST['33'];
$dater = $_POST['11']." - ". $_POST['22']." - ". $_POST['33'];
<?php
// if ('POST' === $_SERVER['REQUEST_METHOD'])
if (isset($_POST['submit2']))
{
$con = mysql_connect("localhost","rabbitju_rjziond","r4bb1t");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("rabbitju_rjreservation", $con);
$daters = $_POST['11']." ". $_POST['22']." ". $_POST['33'];
$dater = $_POST['11']." - ". $_POST['22']." - ". $_POST['33'];
//Writes the to the server
$sql = mysql_query("INSERT INTO `reservation__date` (`reservation_id`, `reservation_date`)
VALUES
('daters', '$dates')") or die(mysql_error());
$query = mysql_query($sql);
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
echo "Succesfully added transaction. Updating table...";
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"6\">";
mysql_close($con);
}
}
?>
答案 0 :(得分:0)
$sql = mysql_query("INSERT INTO `reservation__date` (`reservation_id`, `reservation_date`) VALUES ('$daters', '$dates')") or die(mysql_error());
''daters'之前没有$
答案 1 :(得分:0)
使用以下查询。您忘记为booking_id值添加的$符号。
$sql = mysql_query("INSERT INTO `reservation__date` (`reservation_id`, `reservation_date`) VALUES ('".$daters."', '".$dates."')");