Php 完整日历未更新到数据库
我已经搜索并尝试了几乎所有我遇到的事情,但没有运气。所有正确的参数都显示在控制台日志中,但不知何故没有传递到数据库。希望有人能解释一下 update.phpPhp 完整日历未更新到数据库,php,mysql,Php,Mysql,我已经搜索并尝试了几乎所有我遇到的事情,但没有运气。所有正确的参数都显示在控制台日志中,但不知何故没有传递到数据库。希望有人能解释一下 update.php <?php /* Values received via ajax */ $Job = $_POST['id']; $date_assigned = $_POST['start']; // connection to the database try { $bdd = new PDO('mysql:host=localho
<?php
/* Values received via ajax */
$Job = $_POST['id'];
$date_assigned = $_POST['start'];
// connection to the database
try {
$bdd = new PDO('mysql:host=localhost;dbname=service', 'root', 'root');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
// update the records
$sql = "UPDATE install SET date_assigned=? WHERE Job=?";
$q = $bdd->prepare($sql);
$q->execute(array($date_assigned,$Job));
?>
所以,对我来说答案很简单。我的数据库没有设置密码,我在连接中指定了一个密码。一旦我移除了它,它就如预期的那样工作了。谢谢你的帮助。很抱歉在我本该抓到的愚蠢的事情上浪费时间。你能发布$u post的实际输出吗?它很可能是日期的格式,Mysql希望它是
YYYY-MM-DD HH:MM:SS
如果您使用的是DATETIME字段。请在代码中添加一个错误处理,以便您可以看到问题所在控制台日志正在输出“start:2019-11-14 12:00:00”print\r($\u POST)代码>输出什么?它似乎没有输出任何东西。这是否意味着我没有将参数传递给update语句?没有必要道歉。我一生中的大部分时间都是一名开发人员,像这样的小事情,或是一个缺失的分号,仍然不时让我感到困惑!这是开发中有趣的部分之一!:)
$.ajax({
type: 'POST',
url: 'update.php',
data: 'title=' + info.event.title + '&start='+ start + '&id='+ info.event.id ,
success: function(json) {
console.log('succes:', info.event.title);
console.log('start:', start);
//console.log('Eind tijd:', info.event.end.toISOString().slice(0, 19).replace('T', ' '));
console.log('ID:', info.event.id);
console.log('auto:', recourceid);
calendar.rerenderEvents();
}
});