gpt4 book ai didi

php - MySQL+PHP 错误:mysqli_stmt::execute() 不正确的日期时间值:“

转载 作者:行者123 更新时间:2023-11-28 23:32:06 24 4
gpt4 key购买 nike

我是 PHP 和 MySQLi 的新手,正在尝试创建一个可编辑的分页表。但我卡在了日期时间更新上。

我的添加功能工作正常,但是当我尝试提交编辑表单时出现以下错误:

mysqli_stmt::execute(): (22007/1292): Incorrect datetime value: "for column 'date'

这里是错误行代码的一部分:

$id = $_POST['id'];
$name = htmlentities($_POST['name'], ENT_QUOTES);
$nummer = htmlentities($_POST['nummer'], ENT_QUOTES);
$stuck = htmlentities($_POST['stuck'], ENT_QUOTES);
$cdate = date(' Y-m-d H:i:s');

//check if empty
if($name == '' || $nummer == '' || $cdate = '' || $stuck == ''){
$error = 'ERROR: Please fill in all required fields!';
renderForm($name, $nummer, $cdate, $stuck, $error, $id);
}else{
// if everything is fine, update the record in the database
if($stmt = $mysqli->prepare("UPDATE ware SET name = ?, nummer = ?, date= ?, stuck = ? WHERE id=?")){
$stmt->bind_param("sssii",$name,$nummer, $cdate, $stuck, $id);
if(!$stmt->execute()) echo $stmt->error;
...

完整代码可以在这里找到:http://pastie.org/10824477

最佳答案

@Ravinder Reddy 先于我,但我注意到你在 date 函数中有一个额外的空格:

$cdate = date(' Y-m-d H:i:s');

应该是

$cdate = date('Y-m-d H:i:s');

mysql now() 函数也可以在这里工作。

关于php - MySQL+PHP 错误:mysqli_stmt::execute() 不正确的日期时间值:“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37037620/

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