How do i add the total online and online users
Printable View
How do i add the total online and online users
K the total online first
go to folder www/_inc and open functions.php
Find something like;
below it u might see sumtin like;Code:function totalchars() {
$result = mysql_query("SELECT * FROM characters");
$rows = mysql_num_rows($result);
echo $rows ;
}
blah blahCode:function totalon() {
replace everything in the function totalon() thing with;
Then close functions.php and go back to the www folder and open index.phpCode:function totalon() {
$result = mysql_query("SELECT online FROM accounts WHERE online = '1'");
$rows = mysql_num_rows($result);
echo $rows ;
}
find;
and below it add;Code:Total Characters:
<?php totalchars(); ?>
Code:Total Online:
<?php totalon(); ?>
Then for the onlineusers script i got it from a dif post located at:
http://forum.ragezone.com/f336/relea...rs-php-233331/
then linked it to the page.
u can get my functions.php from:
functions.php - FileFront.com
when i try adding total online i get
Fatal error: Cannot redeclare totalon() (previously declared in C:\wamp\www\website\_inc\functions.php:84) in C:\wamp\www\website\_inc\functions.php on line 93
Quote:
<?php
$online = '<img src="images/server_online.gif" alt="asd" width="20" height="20">';
include('config.php'); # Configuration Load.
function notice($text,$header='',$type='') {
if ($type == 'alert') {
return "$header";
} else {
$key= rand(0,5);
$key = str_pad($key+1, 2, 0, STR_PAD_LEFT);
return "$text";
}
}
function Connect() {
include('config.php'); # Configuration Load.
mysql_connect($config['db']['host'], $config['db']['user'], $config['db']['pass']);
mysql_select_db($config['db']['name']);
}
function get_news() {
require('modules/home.php');
}
function LoginStatus() {
$result = @fsockopen('127.0.0.1', '29000', $ERRNO, $ERRSTR, .02);
if(!$result) {
echo notice('<font color=red>Offline</font>');
} else {
echo notice('<font color=green>Online</font>');
}
}
function WorldStatus() {
$result = @fsockopen('127.0.0.1', '29200', $ERRNO, $ERRSTR, .02);
if(!$result) {
echo notice('<font color=red>Offline</font>');
} else {
echo notice('<font color=green>Online</font>');
}
}
function CharStatus() {
$result = @fsockopen('127.0.0.1', '29100', $ERRNO, $ERRSTR, .02);
if(!$result) {
echo notice('<font color=red>Offline</font>');
} else {
echo notice('<font color=green>Online</font>');
}
}
function banUser() {
$user = addslashes($_POST['ban_username']);
$result = mysql_query("UPDATE accounts SET accesslevel = '-100' WHERE username = '$user'");
if(!$result) {
echo notice('User cannot be banned at the moment because he / she is online, or you entered an invalid user.');
} else {
echo notice('User has been banned successfully.');
}
}
function unbanUser() {
$user = addslashes($_POST['unban_username']);
$result = mysql_query("UPDATE accounts SET accesslevel = '100' WHERE username = '$user'");
if(!$result) {
echo notice('User cannot be unbanned at the moment because he / she is online, or you entered an invalid user.');
} else {
echo notice('User has been unbanned successfully.');
}
}
function totalACC() {
$result = mysql_query("SELECT * FROM accounts");
$rows = mysql_num_rows($result);
echo $rows ;
}
function totalon() {
$result = mysql_query("SELECT online FROM accounts WHERE online = '1'");
$rows = mysql_num_rows($result);
echo $rows ;
}
function totalon() {
$result = mysql_query("SELECT * FROM list_connected");
$rows = mysql_num_rows($result);
echo $rows ;
}
function getUserChars() {
$result = mysql_query("SELECT * FROM characters WHERE account_name = '".$_SESSION['account']."'");
$chars = mysql_fetch_array($result);
}
function userLevels() {
$levels = array(
'-100' => '<font color=red>Banned</font>',
'100' => '<font color=green>Member</font>',
'300' => '<b><font color=green>Administrator</font>',
);
}
function checkAdminLogin() {
$result = mysql_query("SELECT * FROM accounts WHERE username = '$U' and password = '$P' and accesslevel = '300'");
}
function checkUserLogin() {
$result = mysql_query("SELECT * FROM accounts WHERE username = '$U' and password = '$P' and accesslevel = '100'");
}
function errors() {
$reg = array(
'done' => 'Registration Complete!',
'fail' => 'Registration Failed',
'inUs' => 'Username is in use.',
'psM' => 'Passwords dont match!',
);
}
u have it twice
simple fix, delete this one;Code:function totalon() {
$result = mysql_query("SELECT online FROM accounts WHERE online = '1'");
$rows = mysql_num_rows($result);
echo $rows ;
}
function totalon() {
$result = mysql_query("SELECT * FROM list_connected");
$rows = mysql_num_rows($result);
echo $rows ;
}
it runs off old sql table.Code:function totalon() {
$result = mysql_query("SELECT * FROM list_connected");
$rows = mysql_num_rows($result);
echo $rows ;
}
how do u use matts its like got nothing working lol
if i need sumtin i make it or i do it the hard way
also all these updates that ive been posting i added to the main post.
Ok that errors gone now when i go to my website i get
| Total Accounts: 3 | Total Characters: 0
Fatal error: Call to undefined function totalchars() in C:\wamp\www\website\index.php on line 185
where the total player is supost to be
edit
i downloaded your function file and dident help i just get this when i goto site
Total Accounts: 3 | Total Characters: 0 1
k well here is my index too
----------------------------
dont know what u might have done wrong =P
Alright it works thanks so much.
last question. How do i take the popup out?
or maybe not
Oh sorry, lol 1 sec
here; index.php - FileFront.com
thanks sooooo much there was 1 more thing i was going to ask but nvm you have done alot more me thanks so much!
np, if u have anything to ask just do it, ill do my best to answer, also taking ideas, ill see what i can do =P
Alright well you know how on your website you dont need to login unless your going to use user CP or admin CP?
how did you do that?
uhm... i have no clue how i did that... thats just how it was lol
Hmm when i click online users it says page cant be found