<?
$host = "127.0.0.1";
$username = "root";
$password = "root";
$db_name = "l2jdb";
function connect_db() {
mysql_connect("$host", "$username", "$password")or die("Can't connect to the database.");
}
function select_db() {
mysql_select_db("$db_name")or die("Can't select the database.");
}
//query variables
$field = "char_name";
$table = "characters";
$value = "1";
$rule = "online";
connect_db();
select_db();
$query = mysql_real_escape_string(mysql_query("SELECT $field FROM $table WHERE $rule = $value"));
$count = mysql_num_rows($query);
echo "Players online: "$count".";
?>
Haven't tested it, as it doesn't save the result to a file and just display the file I advise not using it on a server that's going to have a lot of traffic going to the website. But as you've asked for this, i doubt you plan on that anyway.