我有一条sql插入语句,该语句插入6个表列中。最后两个使用预定义的值。在sql语句的值部分中,我只是将值放在引号内(并且它在下面的教程中起作用),但是它不起作用。我删除了sql语句中的最后两个值和列,并很好地插入了它们,因此出于某种原因它不采用静态值。谁能发现问题?
if (isset($_POST["submit"])){
$name = $_POST["commenterName"];
$email = $_POST["commenteremail"];
$comment = $_POST["commenterthoughts"];
date_default_timezone_set("Europe/Dublin");
$currenttime = time();
$datetime= strftime("%B-%d-%Y %H:%M:%S", $currenttime);
$sql = "INSERT INTO comments(datetime,name,email,comment,approvedby,status) VALUES(:time,:name,:email,:comment,'pending','off')";
$stmt = $connect->prepare($sql);
$stmt->bindValue(':time',$datetime);
$stmt->bindValue(':name',$name);
$stmt->bindValue(':email',$email);
$stmt->bindValue(':comment',$comment);
$Execute = $stmt->execute();
if($Execute){
$_SESSION["success"] = "data added successfully";
redirect("fullpost.php");
}else {
$_SESSION["error"] = "something went wrong. data not added to table";
redirect("fullpost.php");
}
}