Cetanu Posted July 21, 2009 Share Posted July 21, 2009 <?php include "db.php"; $sql = mysql_query("SELECT COUNT(id) FROM users"); echo "MythScape has " .$sql. " members!"; ?> Why does this return: " MythScape has Resource id #5 members!" ??? Quote Link to comment https://forums.phpfreaks.com/topic/166741-solved-select-count/ Share on other sites More sharing options...
simon551 Posted July 21, 2009 Share Posted July 21, 2009 $query="SELECT id FROM table"; $rs=mysql_query($query,$connection); $row=mysql_fetch_assoc($rs); echo $row['id']; in your case you are trying to echo the mysql operation. You can echo a query but not an operation like mysql_query(); Quote Link to comment https://forums.phpfreaks.com/topic/166741-solved-select-count/#findComment-879246 Share on other sites More sharing options...
Alex Posted July 21, 2009 Share Posted July 21, 2009 Because you want to echo the count, you'd do this: <?php include "db.php"; $sql = mysql_query("SELECT COUNT(id) FROM users"); $row = mysql_fetch_assoc($sql); echo "MythScape has {$row['COUNT(id)']} members!"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/166741-solved-select-count/#findComment-879250 Share on other sites More sharing options...
Cetanu Posted July 21, 2009 Author Share Posted July 21, 2009 Oh okay. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/166741-solved-select-count/#findComment-879381 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.