[PHP] Total Accounts & Characters

Results 1 to 21 of 21
  1. #1
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    [PHP] Total Accounts & Characters

    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!


  2. #2
      Phoenix is offline
    ModeratorRank
    Mar 2009 Join Date
    6,890Posts

    Re: [PHP] Total Accounts & Characters

    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.

    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>&nbsp;» <?php
     
    //Total Characters
    $query mssql_query_logged("SELECT * FROM Character"); 
    $num_rows mssql_num_rows($query); 
    echo 
    "Total Characters: ".$num_rows."<n>";

    ?><br>
    <b>&nbsp;» <?php
     
    //Total Clans
    $query mssql_query_logged("SELECT * FROM Clan"); 
    $num_rows mssql_num_rows($query); 
    echo 
    "Total Clans: ".$num_rows."<n>";

    ?>
    Complete script:

    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">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td background="images/menu_bg.jpg">
    <br>
    <b>&nbsp;» Nolife_x Network:                                                                         <?php
        $ip 
    '66.131.32.2';
        
    $port '6000';
        
    $fp = @fsockopen($ip$port$errno$errstr1);
        if (!
    $fp)
            {
                echo 
    "<font style='color: #FF3300'>Offline</font><br />";
            }
            else
            {
                echo 
    "<font style='color: #009933'>Online</font><br />";
                
    fclose($fp);
            }
        
    ?>

    <b>&nbsp;» 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>&nbsp;» <? //Total Accounts
    $query mssql_query_logged("SELECT * FROM Account"); 
    $num_rows mssql_num_rows($query); 
    echo 
    "Total Accounts: ".$num_rows."<n>"
     
    ?><br> 
    <b>&nbsp;» <?php
     
    //Total Characters
    $query mssql_query_logged("SELECT * FROM Character"); 
    $num_rows mssql_num_rows($query); 
    echo 
    "Total Characters: ".$num_rows."<n>";

    ?><br>
    <b>&nbsp;» <?php
     
    //Total Clans
    $query mssql_query_logged("SELECT * FROM Clan"); 
    $num_rows mssql_num_rows($query); 
    echo 
    "Total Clans: ".$num_rows."<n>";

    ?><br>
    <b>&nbsp;» Visits Today: <?php
    $file_count 
    fopen('counter/count.db''rb');
        
    $data '';
        while (!
    feof($file_count)) $data .= fread($file_count4096);
        
    fclose($file_count);
        list(
    $today$yesterday$total$date$days) = split("%"$data);
        echo 
    $today;
    ?>
    <br>
    <b>&nbsp;» 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">&nbsp;</td>
                                            <td width="142">&nbsp;</td>
                                            <td width="41">&nbsp;</td>
                                        </tr>

                                            </tbody></table>
    <strong>                                </strong></td>
                                </tr>
                                <tr>
                                    <td background="images/menu_foot.gif" height="22">&nbsp;</td>
                                </tr>
    </tbody></table><br>
    Credits to Nolife_x.

  3. #3
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    I am making a custom website but thanks for the scripts.
    Last edited by BGRick; 22-02-11 at 01:03 PM.

  4. #4
    Member ssad56 is offline
    MemberRank
    Jan 2011 Join Date
    50Posts

    Re: [PHP] Total Accounts & Characters

    just a Question, BGRick why do have an infraction on every thread

  5. #5
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    Quote Originally Posted by ssad56 View Post
    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 ?

  6. #6
    Member mutter is offline
    MemberRank
    Dec 2010 Join Date
    ArgentinaLocation
    64Posts

    Re: [PHP] Total Accounts & Characters

    mssql_query_logged, change to : mssql_query

  7. #7
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    Still if I this then:

    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>"
     
    ?>
    It still says:
    PHP Code:
    There are currently "; ?> registered users. 

  8. #8
      Phoenix is offline
    ModeratorRank
    Mar 2009 Join Date
    6,890Posts

    Re: [PHP] Total Accounts & Characters

    Quote Originally Posted by BGRick View Post
    Still if I this then:

    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>"
     
    ?>
    It still says:
    PHP Code:
    There are currently "; ?> registered users. 
    You need to define the variables in your script. The script I posted use variables from that MPOG website's functions.php.

  9. #9
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    Quote Originally Posted by Phoenix View Post
    You need to define the variables in your script. The script I posted use variables from that MPOG website's functions.php.
    Can u maybe make me one with no req. of functions.php just mssql connection and odbcad?

  10. #10
    Member mutter is offline
    MemberRank
    Dec 2010 Join Date
    ArgentinaLocation
    64Posts

    Re: [PHP] Total Accounts & Characters

    Try: <? to <?php
    Change: mssql_query_logged -> mssql_query
    PHP: odbc_connect - Manual
    Last edited by mutter; 22-02-11 at 04:31 PM.

  11. #11
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    If script =
    PHP Code:
    <?
    $query 
    mssql_query("SELECT * FROM Account"); 
    $num_rows mssql_num_rows($query); 
    echo 
    "".$num_rows."<n>"
     
    ?>
    Then I get:
    PHP Code:
    "; ?> 

    If the script is:
    PHP Code:
    <?php
    $query 
    mssql_query("SELECT * FROM Account"); 
    $num_rows mssql_num_rows($query); 
    echo 
    "".$num_rows."<n>"
     
    ?>
    Then I get:
    PHP Code:
    Fatal errorCall to undefined function mssql_query() in C:\Program Files\XAMMP\xampplite\htdocs\source\regusers.php on line 2 

  12. #12
    Member mutter is offline
    MemberRank
    Dec 2010 Join Date
    ArgentinaLocation
    64Posts

    Re: [PHP] Total Accounts & Characters

    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.

  13. #13
    Account Upgraded | Title Enabled! e1o14 is offline
    MemberRank
    Apr 2009 Join Date
    GermanyLocation
    306Posts

    Re: [PHP] Total Accounts & Characters

    PHP 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>';
    ?>
    This one works fine for me, thanks to Zewa

  14. #14
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    Quote Originally Posted by mutter View Post
    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);

    ?>
    PHP Code:
    Parse errorsyntax errorunexpected T_CONSTANT_ENCAPSED_STRINGexpecting ',' 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 ----------

    Quote Originally Posted by e1o14 View Post
    PHP 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>';
    ?>
    This one works fine for me, thanks to Zewa
    PHP Code:
    Fatal errorCall to undefined function mssql_connect() in C:\Program Files\XAMMP\xampplite\htdocs\source\regusers.php on line 8 

  15. #15
    Account Upgraded | Title Enabled! alfredao is offline
    MemberRank
    Jan 2008 Join Date
    Coronel FabriciLocation
    705Posts

    Re: [PHP] Total Accounts & Characters

    Here has my function. It's easy to use.

    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'];

    Usage:

    PHP Code:
    echo total("Accounts"); //Print in screen the total of Accounts 
    PHP Code:
    echo total("Accounts""WHERE UGradeID = 253"); //Print in screen the total of banneds Accounts 
    So, if you want the total of active characters.

    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.

  16. #16
    Member mutter is offline
    MemberRank
    Dec 2010 Join Date
    ArgentinaLocation
    64Posts

    Re: [PHP] Total Accounts & Characters

    Quote Originally Posted by BGRick View Post
    PHP Code:
    Parse errorsyntax errorunexpected T_CONSTANT_ENCAPSED_STRINGexpecting ',' 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 errorCall to undefined function mssql_connect() in C:\Program Files\XAMMP\xampplite\htdocs\source\regusers.php on line 8 
    echo "Total Accounts: ".$execquery " - ";
    change to echo "Total Accounts: ".$execquery." - ";

  17. #17
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    Quote Originally Posted by alfredao View Post
    Here has my function. It's easy to use.

    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'];

    Usage:

    PHP Code:
    echo total("Accounts"); //Print in screen the total of Accounts 
    PHP Code:
    echo total("Accounts""WHERE UGradeID = 253"); //Print in screen the total of banneds Accounts 
    So, if you want the total of active characters.

    PHP Code:
    echo total("Character""WHERE DeleteName IS NULL"); //Print in screen the total of active Characters 
    I don't get this one o.o

    ---------- Post added at 06:29 PM ---------- Previous post was at 06:29 PM ----------

    Quote Originally Posted by mutter View Post
    echo "Total Accounts: ".$execquery " - ";
    change to echo "Total Accounts: ".$execquery." - ";
    If I use that then you get:

    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);

    ?>
    In the site I get this:

    PHP Code:
    Total AccountsResource id #3 - 
    Last edited by BGRick; 22-02-11 at 07:10 PM.

  18. #18
    Member mutter is offline
    MemberRank
    Dec 2010 Join Date
    ArgentinaLocation
    64Posts

    Re: [PHP] Total Accounts & Characters

    Quote Originally Posted by BGRick View Post
    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:

    PHP Code:
    <?php
    $connection 
    odbc_connect('GunzDB','sa''24maart!'
    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);

    ?>
    In the site I get this:

    PHP Code:
    Total AccountsResource id #3 - 
    Oh my bad.

    PHP 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";
    ?>
    PHP: odbc_num_rows - Manual

  19. #19
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    That gives errors like hell...

  20. #20
    Member mutter is offline
    MemberRank
    Dec 2010 Join Date
    ArgentinaLocation
    64Posts

    Re: [PHP] Total Accounts & Characters

    PHP Code:
    <?php
    $con 
    odbc_connect
    ("Driver={SQL Server};
    Server={host\SQLEXPRESS};
    Database={GunzDB}"
    ,
     
    samypass) 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.

  21. #21
    Account Upgraded | Title Enabled! BGRick is offline
    MemberRank
    Oct 2010 Join Date
    The NetherlandsLocation
    437Posts

    Re: [PHP] Total Accounts & Characters

    That didn't worked but with your script I got it working ;)

    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>";

    ?>
    Config.php:
    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"); 

    ?>
    So thanks man!

    /close request



Advertisement