gpt4 book ai didi

php - 如何使用php比较mysql查询中的两个日期时间

转载 作者:行者123 更新时间:2023-12-01 00:43:35 24 4
gpt4 key购买 nike

我想比较两个 datetime 变量,其中一个是当前 server time 而其中一个存储在 mysql 数据库中 我是运行这段简单的代码,它不会工作,并说这是一个语法错误,我想知道我能做什么

    <?php include("includes/student_session.php");?>
<?php confirm_logged_in();?>
<?php include("includes/connection.php");?>
<?php
date_default_timezone_set("");
$now_date=date("Y-m-d H:i:s");

$query1="select exam_id from exam where {$now_date} > start_date";
$result=mysqli_query($cnn,$query1);
if($result){

$row=mysqli_fetch_array($result);
echo $exam_id. "exists";

}else
{echo mysqli_error($cnn);}

?>

最佳答案

在这段代码中:

$query1="select exam_id from exam where {$now_date} > start_date";
$result=mysqli_query($cnn,@query1); // <-

您正在使用 @query1,这应该是 $query1

关于php - 如何使用php比较mysql查询中的两个日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25885145/

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