<?php
require 'dbcon.php';
$rep= isset($_POST['repeat']);
$name= isset($_POST['name']);
$year= isset($_POST['year']);
$month= isset($_POST['month']);
$day= isset($_POST['day']);
$time= isset($_POST['time']);
$SQL_Cal_Table=
"
CREATE TABLE IF NOT EXISTS `eventcalendar`
(
num int AUTO_INCREMENT PRIMARY KEY,
name varchar(255),
year varchar(255),
month varchar(255),
day varchar(255),
time varchar(255),
rep varchar(255)
)
";
$SqlTable=$con->query($SQL_Cal_Table);
$sql_insert=
"
insert into `eventcalendar` (name,year,month,day,time,rep)
values ('".$name."','".$year."','".$month."','".$day."','".$time."','".$rep."')
";
$SqlAddTable=$con->query($sql_insert);
if ($SqlTable&&$SqlAddTable) {
echo "Successfully Added";
}else{
trigger_error('Wrong SQL: ' . $SQL_Cal_Table . ' Error: ' . $con->error, E_USER_ERROR);
}
require 'discon.php';
?>
致命错误:错误的SQL:如果不存在
eventcalendar
,则创建表(num int AUTO_INCREMENT主键,名称为varchar(255),年份为varchar(255),月份为varchar(255),日期为varchar(255),时间varchar(255),rep varchar(255))错误:在第37行的K:\ xampp2 \ htdocs \ eventcalendar-master \ add_event.php中未选择数据库