Jayden_Blade Posted November 24, 2013 Share Posted November 24, 2013 Hey everyone. I am trying to show currently active users. It worked on my server but it will not show up on my live server. navigate.php <?php error_reporting(E_ALL); include "/home/jayden1/database_access/dblogincheck.php"; if(isset($_SESSION['username'])){ $user = $_SESSION['username']; $date = date('c'); mysql_query("replace into navigate ( username, time ) values('$user','$date')"); } ?> showing the list <?php error_reporting(E_ALL); include ("/home/jayden1/database_access/dblogincheck.php"); include ("navigate.php"); $d=date('c',time()-5*60);//last 5 minutes $q=mysql_query("SELECT `username` FROM `navigate` WHERE time>'$d'") or die ("query failed to find".mysql_error()); if(mysql_affected_rows()>0){ print "<ul>"; while($users=mysql_fetch_array($q)){ print "<li>{$users[0]}</li>"; } print "</ul>"; } ?> I just seen that it isn't posting it into the db. Anyone know what I am doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/284221-active-user-issues/ Share on other sites More sharing options...
Ch0cu3r Posted November 24, 2013 Share Posted November 24, 2013 (edited) I just seen that it isn't posting it into the db. You need to debug your queries. Also mysql_affected_rows only works for INSERT, DELETE, REPLACE and UPDATE queries not SELECT queries. You should use mysql_num_rows. Edited November 24, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/284221-active-user-issues/#findComment-1459840 Share on other sites More sharing options...
Jayden_Blade Posted November 25, 2013 Author Share Posted November 25, 2013 Hey everyone. I am trying to show currently active users. It worked on my server but it will not show up on my live server. navigate.php <?php error_reporting(E_ALL); include "/home/jayden1/database_access/dblogincheck.php"; if(isset($_SESSION['username'])){ $user = $_SESSION['username']; $date = date('c'); mysql_query("replace into navigate ( username, time ) values('$user','$date')"); } ?> showing the list <?php error_reporting(E_ALL); include ("/home/jayden1/database_access/dblogincheck.php"); include ("navigate.php"); $d=date('c',time()-5*60);//last 5 minutes $q=mysql_query("SELECT `username` FROM `navigate` WHERE time<>'$d'") or die ("query failed to find".mysql_error()); if(mysql_num_rows($d)>0){ print "<ul>"; while($users=mysql_fetch_array($q)){ print "<li>{$users[0]}</li>"; } print "</ul>"; } ?> everything echos fine. not sure where to go from here. Quote Link to comment https://forums.phpfreaks.com/topic/284221-active-user-issues/#findComment-1459896 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.