Server statistics on website [HELP NEEDED]

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Xvad
Posts: 53
Joined: Sun Mar 21, 2010 1:20 pm

Server statistics on website [HELP NEEDED]

Post by Xvad »

Hello guys,
I have already downloaded many many scripts for online players, castle control, pvp/pk status, etc. but unfortunately non of them work for me. I spent days searching for the problem, but in vain. For example, take a look at this screen: http://img266.imageshack.us/img266/4631/topstatus.png
This happens when a configured "Top_Level" script is opened in Firefox.
Script itself looks like this:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <title></title>    </head>    <body>        <?php//---------CONFIGS---------//$title="Created By Classic Team";  // Page Title Here$type="1"; //Type 1 $server="localhost"; // MySQL IP$user="root"; //MySQL Username$password="******"; //MySQL Password$database="l2jdb"; //MySQL Database$top="100"; //-----END OF CONFIGS-----//  if ($title) {print("<head><title>$title</title></head>");}else {print("<head><title>No Page Title</title></head>");}mysql_connect("$server", "$user", "$password") or die(mysql_error());mysql_select_db("$database") or die(mysql_error()); if($type == '1'){$result = mysql_query("SELECT char_name,level FROM characters where level>0 and accesslevel=0 order by level desc")or die(mysql_error());echo "<center><h3>Top $top Level Players</h3></center><table border=10 align=center><tr> <th>Character</th> <th>Level</th> </tr>";$sum1=0;while($row = mysql_fetch_array( $result )) {		$name = $row['char_name'];		$level = $row['level'];		if ($sum1<$top) {		echo "<tr><td align=center>$name</td><td align=center>$level</td></tr>";		$sum1++;		}	}} else {echo "<center>Please config the variable $type. Make it <b>1</b> for Top Status</center>";}?>    </body></html>
If you have any idea how to fix this issue, please let me know.
Thanks in advance
Probe
Posts: 915
Joined: Thu Sep 03, 2009 6:36 pm
Location: Israel
Contact:

Re: Server statistics on website [HELP NEEDED]

Post by Probe »

are you testing this on your computer or on the web server?
you need to have apache and php installed if on your computer
and make sure the file ends with .php (or any other extension your server knows to look for php at)
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: Server statistics on website [HELP NEEDED]

Post by Zoey76 »

This is the fixed version of your script, tested.
As Probe said you need to save this as (whatever name you want) .php, top10.php
Also this script may flood your your server, since it does a connection to the DB every time someone request the list.
You should use an XML file to cache the list and cron jobs every X hours or with every server restart if its daily.

Code: Select all

<?PHP    $title = "by Zoey76";  // Page Title Here    $server = "localhost"; // MySQL IP    $user = "root"; //MySQL Username    $password = ""; //MySQL Password    $database = "l2jdb"; //MySQL Database    $top="10";?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <?        if (!empty($title))        {            print("<title>$title</title>");        }        else        {            print("<title>Top ".$top."</title>");        }        ?>    </head>    <body>        <?            mysql_connect("$server", "$user", "$password") or die(mysql_error());            mysql_select_db("$database") or die(mysql_error());            //added LIMIT to the query to avoid loading the whole list of char            $result = mysql_query("SELECT char_name, level FROM characters WHERE (level > 0) AND (accesslevel = 0) ORDER BY level DESC LIMIT $top") or die(mysql_error());             print "<center><h1>Top $top Level Players</h1><table><tr><th>Character</th><th>Level</th></tr>";            //improved iteration            while($char = mysql_fetch_array( $result ))            {                echo "<tr><td>".$char['char_name']."</td><td align=center>".$char['level']."</td></tr>";            }            //added end tab for table            print "</table></center>";            //added close db conection            mysql_close();        ?>    </body></html>
Last edited by Zoey76 on Mon Dec 06, 2010 10:02 pm, edited 1 time in total.
Powered by Eclipse 4.30 🌌 | Eclipse Temurin 21 ☕ | MariaDB 11.3.2 🗃️ | L2J Server 2.6.3.0 - High Five 🚀

🔗 Join our Discord! 🎮💬
Xvad
Posts: 53
Joined: Sun Mar 21, 2010 1:20 pm

Re: Server statistics on website [HELP NEEDED]

Post by Xvad »

First of all I want to thank both of you for your replies. Now about the problem - it still exists.
Probe wrote:are you testing this on your computer or on the web server?
you need to have apache and php installed if on your computer
and make sure the file ends with .php (or any other extension your server knows to look for php at)
Can you be more specific, like from where to download apache or php and how to make it work. Although I don't think that this might be a problem as I tested these scripts from many different PCs, both mine and others, so how come that noone has this god damn apache and php? anyways, be kind and explain to me how to work with these things. Thanks
Zoey76 wrote:This is the fixed version of your script, tested.
As Probe said you need to save this as (whatever name you want) .php, top10.php
Also this script may flood your your server, since it does a connection to the DB every time someone request the list.
You should use an XML file to cache the list and cron jobs every X hours or with every server restart if its daily.

Code: Select all

<?PHP	$title = "by Zoey76";  // Page Title Here	$server = "localhost"; // MySQL IP	$user = "root"; //MySQL Username	$password = ""; //MySQL Password	$database = "l2jdb"; //MySQL Database	$top="10";?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">		<?		if (!empty($title))		{			print("<title>$title</title>");		}		else		{			print("<title>Top ".$top."</title>");		}		?>    </head>    <body>        <?			mysql_connect("$server", "$user", "$password") or die(mysql_error());			mysql_select_db("$database") or die(mysql_error());			//added LIMIT to the query to avoid loading the whole list of char			$result = mysql_query("SELECT char_name, level FROM characters WHERE (level > 0) AND (accesslevel = 0) ORDER BY level DESC LIMIT $top") or die(mysql_error()); 			print "<center><h1>Top $top Level Players</h1><table><tr><th>Character</th><th>Level</th></tr>";			//improved iteration			while($char = mysql_fetch_array( $result ))			{				echo "<tr><td>".$char['char_name']."</td><td align=center>".$char['level']."</td></tr>";			}			//added end tab for table			print "</table></center>";			//added close db conection			mysql_close();		?>    </body></html>
I couldn't understand this part:
"Also this script may flood your your server, since it does a connection to the DB every time someone request the list.You should use an XML file to cache the list and cron jobs every X hours or with every server restart if its daily"
can you explain it in better way please and about your fixed script - I still have a problem with it, but somewhat different from the original. Here, take a look at this screen: http://img9.imageshack.us/img9/8331/sastd.png
Have any ideas what could cause it?
Last edited by Xvad on Thu Jul 29, 2010 5:00 am, edited 1 time in total.
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: Server statistics on website [HELP NEEDED]

Post by Zoey76 »

You may want to read the following pages:

Web server
http://en.wikipedia.org/wiki/Web_server
Apache HTTP Server
http://en.wikipedia.org/wiki/Apache_HTTP_Server
PHP
http://en.wikipedia.org/wiki/PHP
LAMP
http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29

This is an example of a server software package:
http://www.appservnetwork.com/

A summary of all the above, you won't be able to use server side scripts (like php ones) without server software running in your PC.
Not every PC has such software, so you must install it to make it work.

If you use one package with Apache/PHP/MySQL try not to install MySQL if you already got MySQL installed for your l2j server.

About the flood thing, well every time you request info from a database, this action consume server resources.
Powered by Eclipse 4.30 🌌 | Eclipse Temurin 21 ☕ | MariaDB 11.3.2 🗃️ | L2J Server 2.6.3.0 - High Five 🚀

🔗 Join our Discord! 🎮💬
Probe
Posts: 915
Joined: Thu Sep 03, 2009 6:36 pm
Location: Israel
Contact:

Re: Server statistics on website [HELP NEEDED]

Post by Probe »

if you're new to this stuff I recommend the xampp bundle
http://www.apachefriends.org/en/xampp-windows.html
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Server statistics on website [HELP NEEDED]

Post by jurchiks »

I would never recommend the 3-in-1. It's much better to set those programs up separately and learn some configs at the same time than to install 3-in-1 and just run an executable. It might be a little harder (I, for one, had problems configuring php to work with apache, the installer didn't add the right lines in httpd.conf, but that was the ONLY problem ever), but it's worth it.
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.
Xvad
Posts: 53
Joined: Sun Mar 21, 2010 1:20 pm

Re: Server statistics on website [HELP NEEDED]

Post by Xvad »

The problem occured because of I was testing scripts on local machine without having apache and all the other necessary programs. Now when I have them, everything works fine. Thanks all of you for replying and helping.
Probe
Posts: 915
Joined: Thu Sep 03, 2009 6:36 pm
Location: Israel
Contact:

Re: Server statistics on website [HELP NEEDED]

Post by Probe »

you're welcome
Post Reply