Posted: Sat Aug 12, 2006 5:02 pm Post subject: phpBB2 database output
My PHP + MYSQL skills are minimal however ive tried to have a go at it but I cant seem to get it to work. What I want is to select how many users have registerd to my phpBB2 forums and output it to a PHP page.
The problem here is that you are trying to use the variable result as if it held an integer. If you look at the PHP docs you will notice that it holds a 'resource' (see this link, under heading Return values).
mysql_connect($host, $username, $password);
@mysql_select_db($database) or die("Problem selecting database.");
$sql_newestuser = "SELECT * FROM phpbb_users WHERE user_id > -1 ORDER BY user_id DESC LIMIT 1";
$do_newestuser = mysql_query($sql_newestuser);
$sql_usercount = "SELECT * FROM phpbb_users WHERE user_id > -1";
$do_usercount = mysql_query($sql_usercount);
while ($result = mysql_fetch_array($do_newestuser))
echo "Newest User: ".$result['username'];
echo "Total users: ".mysql_num_rows($do_usercount);
?>
As you can tell, it displays both the newest username and the total number of users. (While there is an easier way to do what this code does, this is just a rough example.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
Featured Links*
Looking for more Windows Networking info?
Sign up to the WindowsNetworking.com Monthly Newsletter, written by Enterprise Security MVP Deb Shinder, containing news, the hottest tips, Networking links of the month and much more. Subscribe today and don't miss a thing! View a sample newsletter.
Become a WindowsNetworking.com member!
Discuss your Windows Networking issues with thousands of other Windows Newtorking experts. Click here to join!