[REQUEST] - PHP Numbers of online users script?
Hi guys http://www.emupedia.com/community/im...lies/smile.gif,
So I am trying to integrate some php codes on my own website that I have created, and im not that a great PHP coder.
I have made it possible to show if the realm and world server is online or offline both with text and image, but now I need a script to show how many users is online on the server.
I was hoping that some of you PHP coders here would have one saved for a request like this, that would really save my weekend http://www.emupedia.com/community/im...lies/smile.gif!
I will be happy to show how that outcome will be http://www.emupedia.com/community/im...lies/smile.gif
And I DID use the search button and looked all over the forum. I have also tried to see if I could rewrite the code from an existing mangos website, but its just too complicated http://www.emupedia.com/community/im...lies/smile.gif
Thanks in advance and have a nice day!
Re: [REQUEST] - PHP Numbers of online users script?
From what I can remember mangos had a field in the user table called 'online' or something. Where the value would be changed to 1 (or something similar) if a user was online.
Knowing that, you can pretty easily write a script.
PHP Code:
$query_online = mysql_query("SELECT * FROM `user_table(change this)` WHERE `online` = '1' ")
$online = mysql_num_rows($query_online);
That's it. :):
Re: [REQUEST] - PHP Numbers of online users script?
Hi,
Thanks for the script :)! I have been trying to integrate it, but I get this error
PHP Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\online.php on line 6
My code looks like this
PHP Code:
<?php
$connection = @mysql_connect("localhost", "XXXX", "XXXX")
or die(mysql_error());
$query_online = mysql_query("SELECT * FROM `Characters` WHERE `Online` = '1' ");
$online = mysql_num_rows($query_online);
?>
And is included on the index site ofc :)
Know what might went wrong here?
EDIT: Im using MySQL 6.0.1 btw :)
:)
Re: [REQUEST] - PHP Numbers of online users script?
Change:
PHP Code:
$query_online = mysql_query("SELECT * FROM `Characters` WHERE `Online` = '1' ");
To:
PHP Code:
$query_online = mysql_query("SELECT * FROM `Characters` WHERE `Online` = '1' ") or die(mysql_error());
And post the error.
Re: [REQUEST] - PHP Numbers of online users script?
PHP Code:
<?php
$connection = @mysql_connect("localhost", "XXXX", "XXXX") or die(mysql_error());
$select = mysql_select_db("DATABASE", $connection);
$query_online = mysql_query("SELECT * FROM `Characters` WHERE `Online` = '1' ");
$online = mysql_num_rows($query_online);
?>
Re: [REQUEST] - PHP Numbers of online users script?
Does the row Online exist? (non-cap'd maby)
Re: [REQUEST] - PHP Numbers of online users script?
He just didnt select a db.. right ? :P
Re: [REQUEST] - PHP Numbers of online users script?
Quote:
Originally Posted by
EliteGM
He just didnt select a db.. right ? :P
Probably, lol. :P
Re: [REQUEST] - PHP Numbers of online users script?
Yay, it works now :)!
It was because I didnt have the characters db selected. Thought that was done in another config file that was included :)
Thanks to all of you! You were a great help I must say!
Here is a screenshot of the outcome :)!
http://www.legendary-league.com/imgs/phpoutcome.jpg