• Networking: The investigation is still on the way, we've switched to backup telecom carriers since the episode but we're still working in settling everything as it must be. We'll add more updates as we have them available. Incoming and outgoing emails will be restricted, and user registration has been disabled until the issue is resolved.

[Release] Online Player Script

Newbie Spellweaver
Joined
Jan 27, 2007
Messages
34
Reaction score
1
Location
Canada
Hi,

i have made a small script which show all online player.

PHP:
<center>
<h1>Online Players</h1><br>
<b><?
mysql_connect('localhost','username','password');
mysql_select_db('bdd');
$result = mysql_query("SELECT * FROM accounts WHERE online = '1'");
$rows = mysql_fetch_array($result);
echo $rows['username'] ;
?>

Demo :
 
Last edited:
Code:
mysql_connect('localhost','username','password');
mysql_select_db('bdd');

change localhost for your ip,
change username for your mysql account
change password for your mysql password
change bdd for your bdd, i use rose
 
Yes Kamizake, i did changed it but still won't say whos only. Only thing it says is " Online Players" :S any idea?
 
Use that and say if you got error :

PHP:
<style type="text/css">
<!--
.Style1 {
	color: #FF0000;
	font-weight: bold;
	font-size: 14px;
	font-family: Geneva, Arial, Helvetica, sans-serif;
}
body,td,th {
	color: #000000;
}
-->
</style>
<center>
<h1>Online Players</h1><br><?
mysql_connect('localhost','root','1110246') or die(mysql_error());
mysql_select_db('rose');
$result = mysql_query("SELECT * FROM accounts WHERE online = '1'") or die(mysql_error());
while($rows = mysql_fetch_assoc($result)) {
echo '<table width="150" border="1" bordercolor="#333333">';
echo '<tr><td><center><b>'.$rows['username'].'</td></tr>';
echo '</table>';
}
?>

I have add some css to it and mysql_error
 
If your using -Elements "RoseOnlineCMS Lite" use this. Same thing, but when the config.php changes so does this..

Code:
<style type="text/css">
<!--
.Style1 {
    color: #FF0000;
    font-weight: bold;
    font-size: 14px;
    font-family: Geneva, Arial, Helvetica, sans-serif;
}
body,td,th {
    color: #000000;
}
-->
</style>
<center>
<h1>Online Players</h1><br><?
mysql_connect($config['db']['host'],$config['db']['user'],$config['db']['pass']) or die(mysql_error());
mysql_select_db($config['db']['name']);
$result = mysql_query("SELECT * FROM accounts WHERE online = '1'") or die(mysql_error());
while($rows = mysql_fetch_assoc($result)) {
echo '<table width="150" border="1" bordercolor="#333333">';
echo '<tr><td><center><b>'.$rows['username'].'</td></tr>';
echo '</table>';
}
?>

By the way, It works great!! Thanks for this.
 
Last edited:
meh still won't work..

I also tried this, copyed pasted the code, saved as onlinestatus.php and placed it inside "inc" folder in my web server, then in the serverstatus.php i made a php form and inside i typed " include("./inc/onlinestatus.php"); " but din't work.
 
well when i use ur last php code it trys to connect to a dif ip other than mine thats in the config.php
 
ik.. im getting that error to, something like connection failed for OBDSlocalhost using pw no, something like that..
 
Lolz dude, it shows the account name online, not shows the player name online
Use this in ROSE CMS
<style type="text/css">
<!--
.Style1 {
color: #FF0000;
font-weight: bold;
font-size: 14px;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
body,td,th {
color: #000000;
}
-->
</style>
<center>
<h1>Online Players</h1><br><?

$db = mysql_connect('localhost', 'root', '') or die("Could not connect to server database");
mysql_select_db('roseon');

$result = mysql_query("SELECT * FROM accounts WHERE online = '1'", $db) or die(mysql_error());

while($row = mysql_fetch_array( $result )) {
echo "<strong>".$row['lastchar']."<BR></strong>";
}
mysql_close($db);
?>
 
Back