本文介绍了我如何“回声"? “资源ID#6"从PHP的MySql响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个非常简单的问题,我有这个问题:
very simple question, i have this:
$datos1=mysql_query("SELECT TIMEDIFF(NOW(), '" . $row['fecha'] . "');");
echo($datos1);
但是结果是:资源ID#6
我如何按照预期的方式打印结果?谢谢!
How can i print the result in the way is meant to be? Thanks!
推荐答案
您需要使用提取功能.例如:
You need to use a fetch function. for example:
$result = mysql_query(sprintf("SELECT TIMEDIFF(NOW(), '%s') as time_delta", $row['fecha']));
if($result){
$data = mysql_fetch_assoc($result);
echo $data['time_delta'];
}
但是,除非绝对必要,否则我不会使用mysql
函数.不建议将mysql
扩展名用于新项目.相反,您应该将 PDO
与PDO_mysql
或.
However, i wouldnt use the mysql
functions unless absolutely necessary. the mysql
extension is NOT recommended for use in new projects. Instead you should use PDO
with PDO_mysql
or mysqli
.
这篇关于我如何“回声"? “资源ID#6"从PHP的MySql响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!