我有在 mysql 中运行良好的 sql 语句,我正在使用 datediff。当我尝试在 php 中使用它时,我得到一个“mysql_fetch_arrary() 期望参数 1 是一个资源,boolean given in”
这个说法是...
$result = mysql_query("select hname, hsn, hmodel, hmake, htype, hwar, datediff(`hwar`, now()) from host where stype='physical';",$db);
我知道该语句在 mysql 中有效
mysql> select hname, hsn, hmodel, hmake, htype, hwar, datediff(`hwar`, now()) from servers.host where stype='physical';
+--------------+---------+--------+-----------+-------+------------+-------------------------+
| hname | hsn | hmodel | hmake | htype | hwar | datediff(`hwar`, now()) |
+--------------+---------+--------+-----------+-------+------------+-------------------------+
| moscow | XXXXXXX | Dell | PowerEdge | R710 | 2013-09-13 | 225 |
| sydney | XXXXXXX | Dell | PowerEdge | R710 | 2013-09-15 | 227 |
当我删除datediff(
hwar, now())
时,我的页面可以工作。我想用它作为字段
$datediff=$row['datediff'];
关于为什么它不起作用的任何线索?