这是我的查询
$sql= "select count(event_id) as cnd from wp_em_events where DATEDIFF (event_end_date, CURDATE()) > 0 and event_status= 1";
$result= mysql_query($sql);
$row= mysql_fetch_assoc($result);
return $row['cnd'];
这在localhost中工作正常,但在服务器中没有,并且返回此错误1305 - FUNCTION DATEDIFF不存在
答案 0 :(得分:0)
尝试将DATEDIFF放在括号中:
$sql= "select count(event_id) as cnd from wp_em_events where
(DATEDIFF (event_end_date, CURDATE())) > 0 and event_status= 1";
我认为phpMyAdmin中还有一个错误,这意味着你必须在最后放置一个LIMIT才能让它工作,所以试试这个:
$sql= "select count(event_id) as cnd from wp_em_events where
(DATEDIFF (event_end_date, CURDATE())) > 0 and event_status= 1 LIMIT 0,10";