www.webdeveloper.com
Results 1 to 3 of 3

Thread: Forum member count

  1. #1
    Join Date
    Jun 2011
    Posts
    141

    Forum member count

    I am trying to get a page to display a total number of members on my forum so have done the following:

    created a page containing:

    Code:
        <?php
        $db_host = 'localhost';
        $db_user = 'xx';
        $db_password = 'xx';
        $db_name = 'adejones_phpb1';
    
        mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
        mysql_select_db($db_name) or die(mysql_error());
    
        $result = mysql_query("SELECT num_users as count FROM phpbb_config");
        echo 'Total members: '.$result['count'].'<br>';
        ?>
    All this does it display "Total members:" with no value afterwards, what am I doing wrong here?

    Thanks, Adey

  2. #2
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    The following snippet can get you closer to your goal:
    Code:
     
    $result = mysql_query("SELECT num_users as count FROM phpbb_config");
    if(mysql_num_rows($result)==0)
        echo 'There are no members. '.'<br>';
    else{
        $data=mysql_fetch_assoc($result);
        echo 'Total members: '.$data['count'].'<br>';
    }

  3. #3
    Join Date
    Jun 2011
    Posts
    141
    Hi WyCnet

    That code gave me the following:

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/adejones/public_html/membercount.php on line 11
    There are no members.

    I did get a bit closer with the following though:

    Code:
    $query = "SELECT config_value FROM phpbb_config WHERE config_name='num_users'";
    $result = mysql_query($query);
    $array=mysql_fetch_assoc($result);
    print_r($array);
    This gives me:

    Array ( [config_value] => 974 )

    Now I just need to get rid of the array config value bit and have just the number.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles