0

我对此有疑问。我正在尝试使这些字段组合在一起,一个带有 - 一个不插入到数据库中

$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);
}
}
?>
4

2 回答 2

0
$sql = mysql_query("INSERT INTO `reservation__date` (`reservation_id`, `reservation_date`) VALUES ('$daters', '$dates')") or die(mysql_error()); 

在“约会者”之前没有 $

于 2013-08-17T08:55:07.753 回答
0

使用下面的查询。您忘记为 reservation_id 值添加的 $ 符号。

$sql = mysql_query("INSERT INTO `reservation__date` (`reservation_id`, `reservation_date`) VALUES ('".$daters."', '".$dates."')");
于 2018-04-07T05:10:19.993 回答