Hey, just need some direction of where to put this line of code to make it show the amount of users registered on my phpBB forum.
The tutorial I’m using gives this code, for the basic forum stats:
<?php
# Database info, or include a config.php file
$db_host = 'localhost'; # Change to your host
$db_user = 'username'; # Change to your user name
$db_password = 'password'; # Change to your password
$db_name = 'database_name'; # Change to your db name
# Connect to the database, or end all scripts and give the reason for ending
mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
# Initialize an array that will contain the stats till the end.
$stats = array();
# Select the number of users online
$result = mysql_query("SELECT count(session_logged_in) as logged_in FROM phpbb_sessions WHERE session_logged_in = 1");
# This gets the result of the above query and stores it in a variable so we can access the result we need
$r = mysql_fetch_array($result);
# Here we store the needed result into the stats array
$stats['logged_in'] = $r['logged_in'];
# Select the newest member
$result = mysql_query("SELECT user_id, username FROM phpbb_users ORDER BY user_id DESC LIMIT 1");
# Using the same method as before, get the result
$r = mysql_fetch_array($result);
# Now we need to store 2 results into the array, the newest user's name, and id
$stats['user_id'] = $r['user_id'];
$stats['username'] = $r['username'];
# Now we need to total amount of topics the forum has
$result = mysql_query("SELECT count(topic_id) as topic_total FROM phpbb_topics");
# Guess what... we now get the result into an array again...
$r = mysql_fetch_array($result);
# And the store it again...
$stats['topic_total'] = $r['topic_total'];
# Select total amount of posts
$result = mysql_query("SELECT count(post_id) as post_total FROM phpbb_posts");
$r = mysql_fetch_array($result);
$stats['post_total'] = $r['post_total'];
# Now we can move onto the really fun stuff, getting everything to display.
# For that, we'll use the echo function. Make sure you change the link to go to your forums.
echo "Users online: {$stats['logged_in']}<br>
Newest registerd user:<br>
<a href=\"http://domain.com/forum/profile.php?mode=viewprofile&u={$stats['user_id']}\">{$stats['username']}</a><br><br>
Total topics: {$stats['topic_total']}<br>
Total Posts: {$stats['post_total']}";
?>
The tutorial says to insert the line:
SELECT count(user_id) as count FROM phpbb_users WHERE user_id != -1
To add the amount of users registered to come up. It doesn’t say where to insert it, so can anyone help me out?
NOTE: The sites support forums are down, so thats why I came here.