• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Help] Please, help with the users online

Newbie Spellweaver
Joined
Feb 24, 2014
Messages
21
Reaction score
0
Hi everyone, i have a problem whit the users online, when i tried to show the users online in the notice.php the users is incremented automatically in "concurrentuser" for example, in my server are 4 users in the notice.php are 4-6-8-10-12-14-16-18 ......... i tried to solve this, but i can´t maybe some one helpme please.
 
Newbie Spellweaver
Joined
Feb 24, 2014
Messages
21
Reaction score
0
Hi, i'm using this php

<?php echo $total = mysql_num_rows(mysql_query("SELECT * FROM concurrentuser")); //echo $total; ?>


Maybe u can help me with this problem, thanks :)
 
Junior Spellweaver
Joined
Oct 9, 2009
Messages
187
Reaction score
29
SELECT SUM(`UserCount`) FROM
(
SELECT
`UserCount`
FROM
`concurrentuser`
WHERE `Time` =
( SELECT
MAX(`Time`)
FROM
`concurrentuser`
WHERE `ServerPort` = '8360')
UNION
SELECT
`UserCount`
FROM
`concurrentuser`
WHERE `Time` =
( SELECT
MAX(`Time`)
FROM
`concurrentuser`
WHERE `ServerPort` = '8361')
) cnt

i already sum it so just replace the php query SELECT * FROM concurrentuser inside

concurrentuser is time based, its logs the online users per value, so even there is no player in the servers, its will just add rows in concurrentuser per minute.

if you have more than 2 servers, just add another

UNION SELECT
`UserCount`
FROM
`concurrentuser`
WHERE `Time` =
( SELECT
MAX(`Time`)
FROM
`concurrentuser`
WHERE `ServerPort` = '836x')
after
WHERE `ServerPort` = '8361')
in the current query
 
Junior Spellweaver
Joined
Oct 9, 2009
Messages
187
Reaction score
29
mysql_select_db('gunbound');
$query = "SELECT SUM(`UserCount`) ol FROM (SELECT `UserCount` FROM `concurrentuser` WHERE `Time` = ( SELECT MAX(`Time`) FROM `concurrentuser` WHERE `ServerPort`='8360')) cnt GROUP BY `UserCount`;";
$result = mysql_query($query, $conn );

if (!$result) exit("The query did not succeded");
else {
while ($row = mysql_fetch_array($result)) {
echo "Online: "+ $row['ol'];
}
}

you dont need to count the rows, just display the row value returned.
 
Junior Spellweaver
Joined
Oct 9, 2009
Messages
187
Reaction score
29
<?php

$servername = "localhost";
$username = "root";
$password = "";
$conn = mysql_connect($servername, $username, $password);

// Check connection

if(! $conn ) {
die('Could not connect: ' . mysql_error());
}



mysql_select_db('gunbound');
$query = "SELECT SUM(`UserCount`) ol FROM (SELECT `UserCount` FROM `concurrentuser` WHERE `Time` = ( SELECT MAX(`Time`) FROM `concurrentuser` WHERE `ServerPort`='8360')) cnt GROUP BY `UserCount`;";
$result = mysql_query($query, $conn );

if (!$result) exit("The query did not succeded");
else {
while ($row = mysql_fetch_array($result)) {
echo "Online: ". $row['ol'];
}
}
?>
use this one
 
Newbie Spellweaver
Joined
Feb 24, 2014
Messages
21
Reaction score
0
Hi bro, I have a problem, when I tried to join my other server (8361)I have a problem, how I can join the server 8360 and 8361? I'm use the sentence UNION, I'm using your PHP :)

<?php

$servername = "XXX.XXX.XXX.XXX";
$username = "root";
$password = "XXXXXXXX";
$conn = mysql_connect($servername, $username, $password);

// Check connection

if(! $conn ) {
die('Could not connect: ' . mysql_error());
}



mysql_select_db('gunbound');
$query = "SELECT SUM(`UserCount`) ol FROM (SELECT `UserCount` FROM `concurrentuser` WHERE `Time` = ( SELECT MAX(`Time`) FROM `concurrentuser` WHERE `ServerPort`='8360')) cnt GROUP BY `UserCount`;";
UNION
SELECT `UserCount` FROM `concurrentuser` WHERE `Time` = ( SELECT MAX(`Time`) FROM `concurrentuser` WHERE `ServerPort`='8361') cnt GROUP BY `UserCount`;
$result = mysql_query($query, $conn );

if (!$result) exit("The query did not succeded");
else {
while ($row = mysql_fetch_array($result)) {
echo "Online: ". $row['ol'];
}
}
?>
 
Back
Top