ServeSATAN Posted August 21, 2010 Posted August 21, 2010 Hello Ladies. I want to share my create Max Online PHP Script. I think many of you search this and can't find. So let's start: create maxonline.sql and write /* MySQL Data Transfer Source Host: localhost Source Database: l2jdb Target Host: localhost Target Database: l2jdb Date: 21.08.2010 14:10:39 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for maxonline -- ---------------------------- DROP TABLE IF EXISTS `maxonline`; CREATE TABLE `maxonline` ( `MaxOnline` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- ---------------------------- -- Records -- ---------------------------- INSERT INTO `maxonline` VALUES ('1'); Next execute this sql file in Navicat. now create in root directory of site maxonline.php and write <?php $mysql_host="localhost"; // MySQL Host [localhost] $mysql_port="3306"; // MySQL Port [3306] $mysql_db="l2jdb"; // MySQL Database [l2jdb] $mysql_login="root"; // MySQL User [root] $mysql_password="master"; // MySQL Password [root] $link = mysql_connect($mysql_host, $mysql_login, $mysql_password) or die("<br>Could not connect: " .mysql_error()); @mysql_select_db($mysql_db, $link); ?> <? $sql = mysql_query("SELECT count(*) FROM characters WHERE online = 1") or die("Invalid query: " .mysql_error()); $playsonline = mysql_result($sql, 0, 0); $sql = mysql_query("SELECT maxonline FROM maxonline") or die("Invalid query: " .mysql_error()); $playsmaxonline = mysql_result($sql, 0, 0); if($playsmaxonline < $playsonline) { mysql_query("UPDATE maxonline SET maxonline='$playsonline'") or die("Invalid query: " .mysql_error()); } ?> <?php echo $playsmaxonline; ?> then include this file in your template :) Credits to me
Fran-FX! Posted September 9, 2010 Posted September 9, 2010 luzzifer speak in english please, and thanx for the share men, keep sharing :D
z3rocool Posted September 15, 2010 Posted September 15, 2010 it`s a simple script, i think i will use it for my website... ;)
Trance Posted September 15, 2010 Posted September 15, 2010 Eh, Simple & useful for website :) Good job, Thanks.
SoRa Posted March 21, 2011 Posted March 21, 2011 Eh, Simple & useful for website :) Good job, Thanks.
Howl3r Posted March 21, 2011 Posted March 21, 2011 Why do you need a whole table just to get the max online users? Why just using plain text on it. Like GetOnlinePlayers example: 20 and set it like 20/500 (max online: 500). No offence just saying :) because too many database connection first will slow the database + will slow the website. Oups now see it old topic :S
ArkeyWave Posted March 21, 2011 Posted March 21, 2011 Eh, Simple & useful for website :) Good job, Thanks.
mogo Posted August 15, 2011 Posted August 15, 2011 No it is max online script, as the subject of this post suggests...
Rin4a Posted August 15, 2011 Posted August 15, 2011 To be honest, this script is a nightmare from performance standpoint. Getting online player count EVERY time, when the page loads? I don't think so. It's much better to make it a cron job and execute it every minute or so. Only 60 queries per hour. And as ~LoL~ZozOQ stated: don't use mysql for this task. A plain text file would do just fine.
papagei Posted August 21, 2011 Posted August 21, 2011 What excactly does this script truely intend to do now? I am a little bit confused *sry*
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now