Hey,
Does someone have these scripts.
Just easy that they say: We have currently x characters.
And: There were made x accounts.
Because what I tried, failed :P
Like will be given if it works.
Thanks!
![]()
Hey,
Does someone have these scripts.
Just easy that they say: We have currently x characters.
And: There were made x accounts.
Because what I tried, failed :P
Like will be given if it works.
Thanks!
![]()
This is the part you need for it. Learn to use the Search button next time. Every website has the server status / server information script.
Complete script:PHP Code:<? //Total Accounts
$query = mssql_query_logged("SELECT * FROM Account");
$num_rows = mssql_num_rows($query);
echo "Total Accounts: ".$num_rows."<n>";
?><br>
<b> » <?php
//Total Characters
$query = mssql_query_logged("SELECT * FROM Character");
$num_rows = mssql_num_rows($query);
echo "Total Characters: ".$num_rows."<n>";
?><br>
<b> » <?php
//Total Clans
$query = mssql_query_logged("SELECT * FROM Clan");
$num_rows = mssql_num_rows($query);
echo "Total Clans: ".$num_rows."<n>";
?>
Credits to Nolife_x.PHP Code:<style type="text/css">
@import "final.css";
</style>
<table style="border-collapse: collapse;" id="table4" width="195" border="0">
<tbody><tr>
<td width="195" background="images/serverstatus.gif" height="30"> </td>
</tr>
<tr>
<td background="images/menu_bg.jpg">
<br>
<b> » Nolife_x Network: <?php
$ip = '66.131.32.2';
$port = '6000';
$fp = @fsockopen($ip, $port, $errno, $errstr, 1);
if (!$fp)
{
echo "<font style='color: #FF3300'>Offline</font><br />";
}
else
{
echo "<font style='color: #009933'>Online</font><br />";
fclose($fp);
}
?>
<b> » Player Online: <?php
$query = mssql_query_logged("SELECT * FROM ServerStatus WHERE ServerID = 1");
for($i=0;$i < mssql_num_rows($query);++$i)
{
$row = mssql_fetch_row($query);
echo "$row[1]";
}
?>
<br>
<b> » <? //Total Accounts
$query = mssql_query_logged("SELECT * FROM Account");
$num_rows = mssql_num_rows($query);
echo "Total Accounts: ".$num_rows."<n>";
?><br>
<b> » <?php
//Total Characters
$query = mssql_query_logged("SELECT * FROM Character");
$num_rows = mssql_num_rows($query);
echo "Total Characters: ".$num_rows."<n>";
?><br>
<b> » <?php
//Total Clans
$query = mssql_query_logged("SELECT * FROM Clan");
$num_rows = mssql_num_rows($query);
echo "Total Clans: ".$num_rows."<n>";
?><br>
<b> » Visits Today: <?php
$file_count = fopen('counter/count.db', 'rb');
$data = '';
while (!feof($file_count)) $data .= fread($file_count, 4096);
fclose($file_count);
list($today, $yesterday, $total, $date, $days) = split("%", $data);
echo $today;
?>
<br>
<b> » Total Visits: <?php
echo $total;
?>
</b></b></strong></b><table style="border-collapse: collapse;" width="193" border="0" height="100%">
<tbody><tr>
<td width="4"> </td>
<td width="142"> </td>
<td width="41"> </td>
</tr>
</tbody></table>
<strong> </strong></td>
</tr>
<tr>
<td background="images/menu_foot.gif" height="22"> </td>
</tr>
</tbody></table><br>
I am making a custom website but thanks for the scripts.
Last edited by BGRick; 22-02-11 at 01:03 PM.
just a Question, BGRick why do have an infraction on every thread
See the line?
Its my signature :P
@On Topic @Phoenix.
I use the script but this only appears on the site:
PHP Code:";?>
---------- Post added at 01:25 PM ---------- Previous post was at 01:20 PM ----------
Can u do it in odbcad because that works better at me
or how to fix the mssql thing, maybe something with php.ini ?
mssql_query_logged, change to : mssql_query
Still if I this then:
It still says:PHP Code:<? //Total Accounts
$query = mssql_query("SELECT * FROM Account");
$num_rows = mssql_num_rows($query);
echo "There are currently ".$num_rows." registered users<n>";
?>
PHP Code:There are currently "; ?> registered users.
Try: <? to <?php
Change: mssql_query_logged -> mssql_query
PHP: odbc_connect - Manual
Last edited by mutter; 22-02-11 at 04:31 PM.
If script =
Then I get:PHP Code:<?
$query = mssql_query("SELECT * FROM Account");
$num_rows = mssql_num_rows($query);
echo "".$num_rows."<n>";
?>
PHP Code:"; ?>
If the script is:
Then I get:PHP Code:<?php
$query = mssql_query("SELECT * FROM Account");
$num_rows = mssql_num_rows($query);
echo "".$num_rows."<n>";
?>
PHP Code:Fatal error: Call to undefined function mssql_query() in C:\Program Files\XAMMP\xampplite\htdocs\source\regusers.php on line 2
You have _mssql lib enabled? made the connection to ms-sql?
Try:
PHP Code:<?php
$connection = odbc_connect('GunzDB','sa', 'passsa')
or die('Cant connect to the server');
$sqlquery="SELECT COUNT(*) FROM Account";
$execquery=odbc_exec($connection,$sqlquery);
echo "Total Accounts: ".$execquery " - ";
//close connection
odbc_close($connection);
?>
Last edited by mutter; 22-02-11 at 05:00 PM.
This one works fine for me, thanks to ZewaPHP Code:<?php
//Connect to database
$_MSSQL['Server'] = "";
$_MSSQL['User'] = "sa";
$_MSSQL['Password'] = "";
$_MSSQL['Database'] = "GunzDB";
$connect = mssql_connect($_MSSQL['Server'],$_MSSQL['User'],$_MSSQL['Password']) or die ("Connection to the database has failed");
mssql_select_db($_MSSQL['Database'],$connect) or die ("Couldn't find the database");
//Accounts Created
$query = "SELECT COUNT(*) FROM Account";
$result = mssql_query($query);
$row = mssql_fetch_row($result);
echo 'Accounts Created : <font color="#CC0000">'.$row[0].'</font><br />';
//Characters Created
$query1 = "SELECT COUNT(*) FROM Character";
$result1 = mssql_query($query1);
$row1 = mssql_fetch_row($result1);
echo 'Characters Created : <font color="#CC0000">'.$row1[0].'</font><br />';
//Clans Created
$query2 = "SELECT COUNT(*) FROM Clan";
$result2 = mssql_query($query2);
$row2 = mssql_fetch_row($result2);
echo 'Clans Created : <font color="#CC0000">'.$row2[0].'</font>';
?>
PHP Code:Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\Program Files\XAMMP\xampplite\htdocs\source\regusers.php on line 6
---------- Post added at 05:34 PM ---------- Previous post was at 05:33 PM ----------
PHP Code:Fatal error: Call to undefined function mssql_connect() in C:\Program Files\XAMMP\xampplite\htdocs\source\regusers.php on line 8
Here has my function. It's easy to use.
Usage:PHP Code:function total($tabela, $cond = null)
{
$query = "SELECT COUNT(*) AS total FROM " . $tabela . (($cond != null) ? " " . $cond : "");
$sql = mssql_query($query);
$c = mssql_fetch_array($sql);
return $c['total'];
}
PHP Code:echo total("Accounts"); //Print in screen the total of Accounts
So, if you want the total of active characters.PHP Code:echo total("Accounts", "WHERE UGradeID = 253"); //Print in screen the total of banneds Accounts
PHP Code:echo total("Character", "WHERE DeleteName IS NULL"); //Print in screen the total of active Characters
Last edited by alfredao; 22-02-11 at 06:19 PM.
I don't get this one o.o
---------- Post added at 06:29 PM ---------- Previous post was at 06:29 PM ----------
If I use that then you get:
In the site I get this:PHP Code:<?php
$connection = odbc_connect('GunzDB','sa', 'password')
or die('Cant connect to the server');
$sqlquery="SELECT COUNT(*) FROM Account";
$execquery=odbc_exec($connection,$sqlquery);
echo "Total Accounts: ".$execquery." - ";
//close connection
odbc_close($connection);
?>
PHP Code:Total Accounts: Resource id #3 -
Last edited by BGRick; 22-02-11 at 07:10 PM.
Oh my bad.
PHP: odbc_num_rows - ManualPHP Code:<?php
$cxn = odbc_connect("GunzDB", "sa", "pass");
$sql = "SELECT * FROM Account'";
$res = odbc_exec($cxn, $sql);
$items = 0;
while ($row = odbc_fetch_array($res))
{
$items++;
}
odbc_free_result($res);
echo "<br>total No. of rows: $items";
?>
That gives errors like hell...
PHP Code:<?php
$con = odbc_connect
("Driver={SQL Server};
Server={host\SQLEXPRESS};
Database={GunzDB}",
sa, mypass) or die();
# function num_rows ODBC
function num_rows($query)
{
$items = 0;
while( odbc_fetch_row($query) )
{
$items++;
}
odbc_free_result($query);
return $items;
}
# account
$sql = "SELECT * FROM Account";
$res = odbc_exec($con, $sql);
# char
$sql2 = "SELECT * FROM Character";
$res2 = odbc_exec($con, $sql2);
# clan
$sql3 = "SELECT * FROM Clan";
$res3 = odbc_exec($con, $sql3);
$acc = num_rows($res);
$char = num_rows($res2);
$clan = num_rows($res3);
echo "Nº total of accounts: ".$acc;
echo "<br>";
echo "Nº total of characters: ".$char;
echo "<br>";
echo "Nº total of clans: ".$clan;
echo "<br>";
?>
Last edited by mutter; 22-02-11 at 07:41 PM.
That didn't worked but with your script I got it working ;)
Config.php:PHP Code:<?php include ("config.php") ?>
<?php
# function num_rows ODBC
function num_rows($query)
{
$items = 0;
while( odbc_fetch_row($query) )
{
$items++;
}
odbc_free_result($query);
return $items;
}
# account
$sql = "SELECT * FROM Account";
$res = odbc_exec($connect, $sql);
# char
$sql2 = "SELECT * FROM Character";
$res2 = odbc_exec($connect, $sql2);
# clan
$sql3 = "SELECT * FROM Clan";
$res3 = odbc_exec($connect, $sql3);
$acc = num_rows($res);
$char = num_rows($res2);
$clan = num_rows($res3);
echo "Nº total of accounts: ".$acc;
echo "<br>";
echo "Nº total of characters: ".$char;
echo "<br>";
echo "Nº total of clans: ".$clan;
echo "<br>";
?>
So thanks man!PHP Code:<?php
$dns="GunzDB";
$user="sa";
$pass="password";
$connect=odbc_connect($dns, $user, $pass) or die ("Couldn't connect to the database, we're sorry...");
odbc_exec($connect,"use GunzDB");
?>
/close request