gpt4 book ai didi

php - Fullcalendar MySQL 插入不工作

转载 作者:行者123 更新时间:2023-11-29 02:23:06 26 4
gpt4 key购买 nike

由于所有“Fullcalendar” 指南都已过时(从第一版开始),我不知道如何INSERTSELECT 我的事件到我的 MySQL 数据库中。

INSERT 的 AJAX:

selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Event Title:');
//var url = prompt('Type Event url, if exits:');
if (title) {
var start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
var end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: 'add_events.php',
data: 'title=' + title + '&start=' + start + '&end=' + end,
type: "POST",
success: function (json) {
alert('Added Successfully');
}
});
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},

添加事件.php:

    <?php
// Values received via ajax
$title = $_POST['title'];
$start = $_POST['start'];
$end = $_POST['end'];

// connection to the database
try {
$bdd = new PDO('mysql:host=localhost;dbname=fullcalendar', 'ymartins', '');
} catch(Exception $e) {
exit('Unable to connect to database.');
}

// insert the records
$sql = "INSERT INTO evenement (title, start, end) VALUES (:title, :start, :end )";
$q = $bdd->prepare($sql);
$q->execute(array(':title'=>$title, ':start'=>$start, ':end'=>$end));
?>

错误:

Object doesn't support property or method 'formatDate'

我以前从未使用过 AJAX,所以如果您有 awnser,请您逐步向我解释一下。你真好。

编辑

我的链接

<meta charset='utf-8' />
<link href='../fullcalendar.css' rel='stylesheet' />
<link href='../fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment.min.js'></script>
<script src='../lib/jquery.min.js'></script>
<script src='../lib/jquery-ui.custom.min.js'></script>
<script src='../fullcalendar.min.js'></script>
<script src='../lang/de.js'></script>

最佳答案

$fullCalendar.formatDateVersion2不再支持

现在我们使用 .format() 而不是 .formatDate()

有关升级的更多信息:http://fullcalendar.io/wiki/Upgrading-to-v2/

关于php - Fullcalendar MySQL 插入不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28085102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com