当需要将日期插入mysql表时,提示此错误-
错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 2 行的 '','2013-09-11','1', NULL)' 附近使用正确的语法
这是我的源代码:
if(isset($_POST['submitsub']))
{
$stuid = $_POST['stuid'];
$stuname = $_POST['stuname'];
$stuemail = $_POST['stuemail'];
$stumajor = $_POST['stumajor'];
$appdate = date("Y-m-d");
$appointment = $_POST['date'];
$subno = $_POST['subject'];
$appstatus = 1;
$tri = mysqli_fetch_assoc(mysqli_query($con,"SELECT this_tri FROM trimester"));
$sql = "INSERT INTO application_subject (app_no, tri_id, sub_id, stu_id, stu_name, stu_email, stu_major, app_date, appointment_date, app_status, app_remark)
VALUES (NULL,'$tri[this_tri]','$subno','$stuid','$stuname','$stuemail','$stumajor',$appdate','$appointment','$appstatus', NULL)";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo'<script>alert("Your application has been submited") </script>';
ob_flush();
}
在我的 mysql 上,属性 of 已经设置为 date。