pspfreak101 Posted October 27, 2008 Share Posted October 27, 2008 I'm working on a users online script but it doesn't show the ip address in the database only has the time stamp I have things setup like this, the usersonline.php is required in the header.php which contains the connection and displays the users online. How can I make it so that it adds their ip address to the database? Usersonline.php <?php // Configuration $timeoutseconds = 1100; // 10 minutes $timestamp=time(); $timeout=$timestamp-$timeoutseconds; $ip = substr($REMOTE_ADDR, 0, strrpos($REMOTE_ADDR,".")); $loopcap = 0; while ($loopcap<3 && @mysql_query("insert into useronline values('$timestamp','$ip','$PHP_SELF')")) { // in case of collision $timestamp = $timestamp+$ip{0}; $loopcap++; } @mysql_query("delete from useronline where timestamp<$timeout"); $result = @mysql_query("select distinct ip from useronline"); $user = @mysql_num_rows($result); mysql_free_result($result); ?> Link to comment https://forums.phpfreaks.com/topic/130273-ip-address-not-showing/ Share on other sites More sharing options...
revraz Posted October 27, 2008 Share Posted October 27, 2008 What does your table structure look like? Why are you suppressing MySQL errors? Why are you not using mysql_error after your queries? Have you echo'd $ip? Link to comment https://forums.phpfreaks.com/topic/130273-ip-address-not-showing/#findComment-675578 Share on other sites More sharing options...
pspfreak101 Posted October 27, 2008 Author Share Posted October 27, 2008 I'm following this tutorial http://elouai.com/users.php I used same table structure as this did Link to comment https://forums.phpfreaks.com/topic/130273-ip-address-not-showing/#findComment-675584 Share on other sites More sharing options...
revraz Posted October 27, 2008 Share Posted October 27, 2008 Can't view that site. Link to comment https://forums.phpfreaks.com/topic/130273-ip-address-not-showing/#findComment-675586 Share on other sites More sharing options...
PFMaBiSmAd Posted October 27, 2008 Share Posted October 27, 2008 Your code is using at least two variables that were depreciated six years ago - $REMOTE_ADDR and $PHP_SELF. I recommend that you develop php code and debug php code on a system where error_reporting is set to E_ALL and display_errors is set to ON to get php to help you find problems like variables that don't exist. Link to comment https://forums.phpfreaks.com/topic/130273-ip-address-not-showing/#findComment-675587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.