Hi, I am working on a website for my server and I want to have most statistic available to view on the site. But of course like always I have issues. I don't know much at all about php, I found this script that's supposed to show my server status (On or Offline). Its a php file and I have no idea where to put it, I have tried copying it to my website in html format but that just shows the whole script on the website. I have tried making a link to pointing to the php file but that does the same thing, Shows the whole script when you click the link. Any help would be appreciated, posted script below. Please no flaming, you don't have to remind me that I'm a newbie at this.
heh, my server has almost the same script for db access...
i have a question of my own too
i'd like the script to access 2 databases
i tried connecting just to the mysql, without the
mysql_select_db($databaseName) or die(mysql_error());
not working
tried using
$query = ("SELECT * FROM lowrate.characters WHERE online=1 and accesslevel=0");
not working
how could i get the script to read data from 2 databases (both on 1 pc)?
the loginserver shares db with 1 gameserver, no problem there, but i want it to read the other db too...
currently it has 2 scripts for both databases, which IMO sucks...
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste! Discussion breeds innovation.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste! Discussion breeds innovation.
I can explain what u want:P but I wont write the code for u:P the main idea is to connect to db1 and update it with what u want after that close connection, after that connect to db2 update it close connection:P
ok, ill try that
i don't need to update them though, just read info, and since they're both on 1 pc i thought maybe there is a way to make it work with single connection for both databases
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste! Discussion breeds innovation.
jurchiks wrote:heh, my server has almost the same script for db access...
i have a question of my own too
i'd like the script to access 2 databases
i tried connecting just to the mysql, without the
mysql_select_db($databaseName) or die(mysql_error());
not working
tried using
$query = ("SELECT * FROM lowrate.characters WHERE online=1 and accesslevel=0");
not working
how could i get the script to read data from 2 databases (both on 1 pc)?
the loginserver shares db with 1 gameserver, no problem there, but i want it to read the other db too...
currently it has 2 scripts for both databases, which IMO sucks...
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste! Discussion breeds innovation.
<?php #Login Server $serverLip="127.0.0.1"; $serverLport="2106"; #GameServer $serverGip="127.0.0.1"; $serverGPort="7777"; #Community Server $servercom="127.0.0.1"; $servercport="9013"; #Database Host $databaseHost="127.0.0.1"; $databaseLogin="root"; $databasePassword="yourdb pw"; $databaseName="L2jDB"; #Server Ip #$address = getenv("REMOTE_ADDR");##echo $address;#// Or simply use a Superglobal ($_SERVER or $_ENV)##$ip = $_SERVER['REMOTE_ADDR'];$ip = gethostbyname('[color=#BF0000]your Homepagename[/color]'); ?> <?php #Login $flogin = @fsockopen ($serverLip,$serverLport, $errno, $errstr, 1); if ( $flogin ) $lstat = "<font color=#00FF00>ONLINE</font>"; else $lstat = "<font color=#FF0000>OFFLINE</font>"; #Sieghardt $fgame2 = @fsockopen ($serverGip,$serverGPort, $errno, $errstr, 1); if ( $fgame2 ) $gstat2 = "<font color=#00FF00>ONLINE</font>"; else $gstat2 = "<font color=#FF0000>OFFLINE</font>"; #Community Server$fcom = @fsockopen ($servercom, $servercport, $errno, $errstr, 1); mysql_connect($databaseHost,$databaseLogin,$databasePassword) or die (mysql_error()); if ( $fcom ) $comstat = "<font color=#00FF00>ONLINE</font>"; else $comstat = "<font color=#FF0000>OFFLINE</font>"; mysql_select_db($databaseName) or die(mysql_error()); //online kari $query = ("SELECT * FROM characters WHERE online=1 and accesslevel=0"); $result = mysql_query($query) or die(mysql_error()); $num2=mysql_numrows($result); $sum=$sum+$num2; //Alliance $query = ("SELECT * FROM clan_data WHERE ally_name!=\"\""); $result = mysql_query($query) or die(mysql_error()); $alliance2=mysql_numrows($result); //all characters $query = ("SELECT * FROM characters WHERE accesslevel>=0"); $result = mysql_query($query) or die(mysql_error()); $char2=mysql_numrows($result); //all GM characters $query = ("SELECT * FROM characters Where accesslevel > 99"); $result = mysql_query($query) or die(mysql_error()); $gmchar2=mysql_numrows($result); //all accounts $query = ("SELECT * FROM accounts WHERE accesslevel>=0"); $result = mysql_query($query) or die(mysql_error()); $accounts2=mysql_numrows($result); //Clan $get_config_data="SELECT clan_id FROM clan_data"; $query = ("SELECT clan_id FROM clan_data WHERE clan_id>0"); $result = mysql_query($query) or die(mysql_error()); $clan2=mysql_numrows($result); //GM $quary = mysql_query ("SELECT char_name FROM characters WHERE accesslevel>100 AND online=1"); while ($gmtitle2 = mysql_fetch_array ($quary)) { $gmname2 = $gmtitle2["char_name"]; } //Titan $quary = mysql_query ("SELECT char_name FROM characters WHERE accesslevel=75 AND online=1"); while ($titantitle2 = mysql_fetch_array ($quary)) { $titanname2 = $titantitle2["char_name"]; } mysql_close(); mysql_connect($databaseHost,$databaseLogin,$databasePassword) or die(mysql_error()); mysql_select_db($databaseName) or die(mysql_error()); ?> <html> <head> <title>MEDNet Lineage II - Kamael Szerver</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"> </head> <body> <font color=#ff9933><span class="style3">Login:</span></font> <?php print ("$lstat"); ?><br> <font color=#ff9933><span class="style3">Game:</span></font> <?php print ("$gstat2"); ?><br> <font color=#ff9933><span class="style3">Community:</span></font> <?php print ("$comstat"); ?><br> <br> <font color=#ff9933><span class="style3">Server IP:</span></font> <font color=#ff0000><?php print ("$ip"); ?></font><br><br> <font color=#ff9933><span class="style3">Spieler online:</span></font> <font color=#ff0000><?php print ("$num2"); ?></font><br> <br> <font color=#ff9933><span class="style3">Accounts:</span></font> <font color=#ff0000><?php print ("$accounts2"); ?></font><br> <font color=#ff9933><span class="style3">Characters:</span></font> <font color=#ff0000><?php print ("$char2"); ?></font><br> <font color=#ff9933><span class="style3">GM Characters:</span></font> <font color=#ff0000><?php print ("$gmchar2"); ?></font><br> <font color=#ff9933><span class="style3">Clans:</span></font> <font color=#ff0000><?php print ("$clan2"); ?></font><br> <font color=#ff9933><span class="style3">Allianzen:</span></font> <font color=#ff0000><?php print ("$alliance2"); ?></font><br> <font color=#ff9933><span class="style3">Online Titan:</span></font> <font color=#ff0000><?php print ("$titanname2"); ?></font><br><br> <font color=#ff9933><span class="style3">Online GM:</span><br></font> <font color=#ff0000><?php print ("$gmname2"); ?></font><br> </html>
Where the red Letters are, u must change to your homepage address for example http://www.test.info. , where ur Gameserver and ur login server is hosted. So u and ur Player can see the address from ur gameserver Ip what must be changed in the windows host file.
How can i make It so you see more then 1 Gm online
<font color=#000000><span class="style3">Online GM:</span><br></font> <font color=#008800><?php print ("$gmname2"); ?></font><br>
if there are 2 gm online you see only 1 name and not 2
thanks