$results=mysql_query("SELECT TIMESTAMPDIFF(SECOND,'2007-12-30 12:01:01','2007-12-31 10:02:00')");
if(!$results)
{
echo mysql_error();
}
else
{
echo $resulta;
}
当我运行此查询时,我获得资源ID#5
答案 0 :(得分:2)
试试这个:
$results = mysql_query("SELECT TIMESTAMPDIFF(SECOND,'2007-12-30 12:01:01','2007-12-31 10:02:00')");
if (!$results) {
echo mysql_error();
} else {
$data = mysql_fetch_assoc($results);
var_dump($data); //check all the data that is returned
}
旁注:您的代码容易受到sql注入攻击。不推荐使用mysql_*
。建议你使用pdo
答案 1 :(得分:2)
$results=mysql_query("SELECT TIMESTAMPDIFF(SECOND,'2007-12-30 12:01:01','2007-12-31 10:02:00')");
while($data=mysql_fetch_row($results)){
//your answer
}
答案 2 :(得分:0)
或者您也可以尝试这种方式
$results=("SELECT TIMESTAMPDIFF(SECOND,'2007-12-30 12:01:01','2007-12-31 10:02:00')");
$re = mysql_query($results) or die("wrong query".mysql_error());
while($row= mysql_fetch_array($re))
{
//your code here
}
并且如上所述,您的代码很容易受到sql注入。