hi
i need help
i have a table with name of "active_users". When any user login then that user is automatically added to this table. what i want to accomplish is to count the number of users that are in this table and then display that figure. i am doing this in php+mysql. So please help me if anybody know the solution for this. i am waiting
need help
Moderator: General Moderators
Re: need help
Careful, you sound impatient. A bad attitude towards us isn't going to help you.doforumda wrote:i am waiting
Code: Select all
SELECT COUNT(*) FROM `active_users`Re: need help
well i already tried this but it displays the following
There are Resource id #4 users currently viewing this site.
i used the following codes and query
$active_user_query = mysql_query("select count(*) from active_users");
echo "<br>There are ".$active_user_query." users currently viewing this site.";
and i apologize saying i am waiting
There are Resource id #4 users currently viewing this site.
i used the following codes and query
$active_user_query = mysql_query("select count(*) from active_users");
echo "<br>There are ".$active_user_query." users currently viewing this site.";
and i apologize saying i am waiting
Re: need help
Try this
Code: Select all
$active_user_query = mysql_query("select count(*) from active_users");
echo "<br>There are ".mysql_num_rows($active_user_query)." users currently viewing this site.";
Re: need help
it give me this warning
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\wamp\www\Login\login.php
how can i remove this warning
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\wamp\www\Login\login.php
how can i remove this warning
Re: need help
You should read the manuals about this. For example, PHP manual for MySQL. http://php.net/mysql
This code is incorrect. Try this one
This code is incorrect. Try this one
Code: Select all
$active_user_query = mysql_query("select count(*) from active_users") or die(mysql_error());
echo "<br>There are ".mysql_result($active_user_query, 0)." users currently viewing this site.";
Re: need help
thanks manits working now when place this
$active_user_query = mysql_query("select count(*) from active_users") or die(mysql_error());
echo "<br>There are ".mysql_result($active_user_query, 0)." users currently viewing this site.";
then it said that No database selected then i give it the database name then it starts wrking
thank you again
$active_user_query = mysql_query("select count(*) from active_users") or die(mysql_error());
echo "<br>There are ".mysql_result($active_user_query, 0)." users currently viewing this site.";
then it said that No database selected then i give it the database name then it starts wrking
thank you again
Re: need help
1) Try to understand this example http://ru2.php.net/manual/en/mysql.examples.php
2) Read about mysql_connect, mysql_select_db and other functions.
2) Read about mysql_connect, mysql_select_db and other functions.