MySQL PHP count(*)返回奇怪的东西 [英] MySQL PHP count(*) returning something weird

查看:101
本文介绍了MySQL PHP count(*)返回奇怪的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行以下查询,希望它返回一个INTEGER,但是它返回"Resource id#3".
我在做什么错了?

I'm running the following query, expecting it to return an INTEGER, but it returns "Resource id #3"
What am I doing wrong?

$queryPlans = mysql_query("SELECT count(*) FROM infostash.rooms");
echo $queryPlans;

此表中实际上有15行,我想返回数字15. 有什么建议吗?

There are actually 15 rows in this table, and I would like to return the number 15. Any suggestions?

推荐答案

您需要:

$queryPlans = mysql_query("SELECT count(*) FROM infostash.rooms");
$row = mysql_fetch_array($queryPlans);
echo $row[0];

mysql_query() 没有返回结果.它返回的资源可以循环遍历并查询行(如上所述).

mysql_query() isn't returning the result. It's returning a resource you can loop across and interrogate for rows (as above).

这篇关于MySQL PHP count(*)返回奇怪的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆