iAaron Posted May 20, 2007 Share Posted May 20, 2007 I have a SQL Database which holds information on the people who are online on my forum. On one of my webpages I want to display a query showing which users are online. How would I use PHP to display the results of this query? Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/ Share on other sites More sharing options...
MadTechie Posted May 20, 2007 Share Posted May 20, 2007 what do you have so far ? it will basically be echo $row['field'] Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/#findComment-257631 Share on other sites More sharing options...
chigley Posted May 20, 2007 Share Posted May 20, 2007 <?php $q = mysql_query("SELECT id, username FROM online_users") or die(mysql_query()); echo "<b>Online Users</b>\n<br />"; while($row = mysql_fetch_assoc($q)) { echo "<a href=\"profile.php?user=$row['id']\">$row['username']</a>"; } ?> Try something like that Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/#findComment-257632 Share on other sites More sharing options...
iAaron Posted May 20, 2007 Author Share Posted May 20, 2007 Ok, this is what I have. <?php $q = mysql_query("SELECT user_id, username FROM phpbb_users WHERE user_active = 0") or die(mysql_query()); echo "<b>Online Users</b>\n<br />"; while($are = mysql_fetch_assoc($q)) { echo "<a href=\"profile.php?user=$are['user_id']\">$are['username']</a>"; } ?> This is the error I am getting : Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/coarsefi/public_html/index.php on line 64 Any ideas what I'm doing wrong? This is the 2nd Time I've used PHP, so yeah... http://www.coarsefishingforums.co.uk/index.php (That is where I am hosting it) Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/#findComment-257648 Share on other sites More sharing options...
radar Posted May 20, 2007 Share Posted May 20, 2007 People should really search before posting... http://www.phpfreaks.com/forums/index.php/topic,140745.0.html Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/#findComment-257654 Share on other sites More sharing options...
iAaron Posted May 20, 2007 Author Share Posted May 20, 2007 I tried that but I get another error. Warning: mysql_query() [function.mysql-query]: Access denied for user: 'nobody@localhost' (Using password: NO) in /home/coarsefi/public_html/index.php on line 60 ??? Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/#findComment-257682 Share on other sites More sharing options...
chigley Posted May 20, 2007 Share Posted May 20, 2007 You need to connect to the database with mysql_connect()! Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/#findComment-257684 Share on other sites More sharing options...
radar Posted May 20, 2007 Share Posted May 20, 2007 Yeah -- and then you will have to modify it to go along with how your table is in your database... note to people: when people give code samples, it is intended for those who have the slightest bit of knowledge about PHP... Quote Link to comment https://forums.phpfreaks.com/topic/52228-solved-users-online/#findComment-257690 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.