player online

any one have any code to see just number off how mach player is online?

i see some php code about player online but that codes crate a page full of player names races ste.

i want just number of player online like

server is up

player online 133!

Do you mean this?


<?php

$Hostname = 'xxx.xxx.xxx.xxx'; // MySQL DB Server IP/Domain

$Username = 'TrinityCore'; // MySQL Username

$Password = 'TrinityCore'; // MySQL Password

$RealmDatabase = 'auth';  // Auth Database


$Body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">


<body>';


$connection = mysql_connect($Hostname, $Username, $Password);


$uptime_query = mysql_query("SELECT * FROM $RealmDatabase.`uptime` ORDER BY `starttime` DESC LIMIT 1", $connection)or die(mysql_error()); 

$uptime_results = mysql_fetch_array($uptime_query);


if ($uptime_results['maxplayers'] > 1) {

	$maxplayers =  $uptime_results['maxplayers'] . ' users.';

} else {

	$maxplayers =  $uptime_results['maxplayers'] . ' user.';

}


$Body .= 'Online Players: ' . $total . '.

</body>

</html>';


echo $Body


?>

[CODE]<?php

$host=“localhost”;

$user=“user”;

$pass=“password”;

$con = mysql_connect($host, $user, $pass);

$condb = mysql_select_db(‘characters’,$con);

if(!$con || !$condb) {

echo "Unable to Connect to Database";

}

else {

$query = mysql_query("SELECT * FROM characters");

while($r=mysql_fetch_array($query)) {

    $on = $r['online'];

    if($on == 1) {

        $players++;

    }

    else {

    }

}

echo "" . $players . " Players Online.";

}

?>[/CODE]

One0 … Too slow /emoticons/default_laugh.png

Try this :


<?php

$Hostname = 'localhost'; // MySQL DB Server IP/Domain

$Username = 'root'; // MySQL Username

$Password = ''; // MySQL Password

$CharDatabase = 'characters';  // Characters Database


$cxn = mysql_connect($Hostname, $Username, $Password);

$db = mysql_select_db ($CharDatabase,$cxn);

	if (!$db) {

		die ('Error : ' . mysql_error());

	}

	$characters_online = mysql_query("SELECT * FROM `characters` WHERE `online` = '1'");	

	$online_players = mysql_num_rows($characters_online);

	if ($online_players > 0) {

		echo '<strong><font color="green">Players online : '.$online_players.'  !</font></strong>';

	}else

	{

		echo '<strong><font color="red">There are no players online!</font></strong>';

	}

?>

Hehehe I didnt see Athena post /emoticons/default_tongue.png

I’m sure the best SQL command for this is:

thanks every one

but this is player online php code any one dont have any realm status?

to see server is up or down?


<?php

require('config.php');

mysql_connect($hostname, $username, $password);

echo 'Players online: '.mysql_result(mysql_query("SELECT COUNT(*) FROM characters.characters WHERE online = 1"), 0);

mysql_close();

?>

Voilà