Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用日期的php mysql where子句_Php_Mysql_Time_Where_Sql Update - Fatal编程技术网

使用日期的php mysql where子句

使用日期的php mysql where子句,php,mysql,time,where,sql-update,Php,Mysql,Time,Where,Sql Update,有人能帮我做以下事情吗 $crDate = date("Y-m-d"); $sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId."AND crDate = ".$crDate; 我试图做的是更新一个表“callrecord”,其中crDate是当前日期。当我把零件拿出来时,它工作得很好 $sql="update callrecord set crEndtime = Now() where crUsId =

有人能帮我做以下事情吗

$crDate = date("Y-m-d");
$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId."AND crDate = ".$crDate;
我试图做的是更新一个表“callrecord”,其中
crDate
是当前日期。当我把零件拿出来时,它工作得很好

$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId;

这个很好用。但我也要查看当前的日期。有什么帮助吗?

您可以使用MySQL函数
curdate()
,而无需在php中进行计算

$sql = "update callrecord set crEndtime = Now() 
        where crUsId = '$crUsId' AND crDate = curdate()";

您可以使用MySQL函数
curdate()
,而无需在php中进行计算

$sql = "update callrecord set crEndtime = Now() 
        where crUsId = '$crUsId' AND crDate = curdate()";

我认为您应该尝试在$crDate周围使用单引号。

我认为您应该尝试在$crDate周围使用单引号。

您通常将日期作为字符串输入,因此需要对其进行引号。例如,
SELECT*FROM Orders,其中OrderDate='2008-11-11'这里。日期时间为“2008-11-1103:29:12”;通常以字符串形式输入日期,因此需要对其进行引用。例如,
SELECT*FROM Orders,其中OrderDate='2008-11-11'这里。日期时间为“2008-11-1103:29:12”;