Hello all, I've recently been getting into PHP to build a website for a Minecraft server I'm running. I've been understanding most of the code, and it's been working well from the snippets of info I get off of various sites... until this. I'm building a MySQL database to store unique IP addresses, along with referrer and browser. After these variables are defined, the information is sent via PHP to my server. I was able to get these working: $BROWSER = $_SERVER['HTTP_USER_AGENT']; $REFERER = $_SERVER['HTTP_REFERER']; PHP: But when I try to get a user's IP address, I always get 192.168.1.64, no matter what I try. Some general questions hopefully answered: 1: I'm testing it externally, this is irrelevant to my local address. 2: My local address is a static 192.168.1.111, so I'm absolutely sure it's not a local address mixup. 3: My local IP is set static by my router, and I have dyndns port forwarding to my external IP, which is also static. 4: I have the MySQL query working properly, it is not causing trouble. 5: I understand PHP and a bit of Apache, but code still needs explaining. 6: I have searched for weeks on how this works, and have tinkered with my code the entire time. 7: I'm assuming it's a problem with my Apache setup, but I am unclear on how to check/fix this. From phpinfo() PHP Version 5.3.10-1ubuntu3.2 System Linux LinuxSplicer 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 Build Date Jun 13 2012 17:02:21 Server API Apache 2.0 Handler Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php5/apache2 Loaded Configuration File /etc/php5/apache2/php.ini Scan this dir for additional .ini files /etc/php5/apache2/conf.d Additional .ini files parsed /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini PHP API 20090626 PHP Extension 20090626 Zend Extension 220090626 Zend Extension Build API220090626,NTS PHP Extension Build API20090626,NTS Debug Build no Thread Safety disabled Zend Memory Manager enabled Zend Multibyte Support disabled IPv6 Support enabled Registered PHP Streams https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, tls Registered Stream Filters zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk PHP Credits Configuration apache2handler Apache Version Apache Apache API Version 20051115 Server Administrator [I]removed[/I] Hostname:Port 127.0.1.1:80 User/Group apache(1002)/1002 Max Requests Per Child: 10000 - Keep Alive: on - Max Per Connection: 100 Timeouts Connection: 300 - Keep-Alive: 5 Virtual Server Yes Server Root /etc/apache2 Loaded Modules core mod_log_config mod_logio itk http_core mod_so mod_rpaf-2 mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_geoip mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_setenvif mod_status Directive Local Value Master Value engine 1 1 last_modified 0 0 xbithack 0 0 Apache Environment Variable Value GEOIP_ADDR 192.168.1.64 HTTP_HOST vanwa-arda-server.dyndns.org HTTP_USER_AGENT Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1 HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_LANGUAGE en-us,en;q=0.5 HTTP_ACCEPT_ENCODING gzip, deflate HTTP_CONNECTION keep-alive HTTP_REFERER http://vanwa-arda-server.dyndns.org/index.php PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games SERVER_SIGNATURE <address>Apache Server at vanwa-arda-server.dyndns.org Port 80</address> SERVER_SOFTWARE Apache SERVER_NAME vanwa-arda-server.dyndns.org SERVER_ADDR 192.168.0.111 SERVER_PORT 80 REMOTE_ADDR 192.168.1.64 DOCUMENT_ROOT /var/www SERVER_ADMIN [I]removed[/I] SCRIPT_FILENAME /var/www/map.php REMOTE_PORT 60477 GATEWAY_INTERFACE CGI/1.1 SERVER_PROTOCOL HTTP/1.1 REQUEST_METHOD GET QUERY_STRING no value REQUEST_URI /map.php SCRIPT_NAME /map.php HTTP Headers Information HTTP Request Headers HTTP Request GET /map.php HTTP/1.1 Host vanwa-arda-server.dyndns.org User-Agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Connection keep-alive Referer http://vanwa-arda-server.dyndns.org/index.php HTTP Response Headers X-Powered-By PHP/5.3.10-1ubuntu3.2 Vary Accept-Encoding Content-Encoding gzip Code (markup): The code inside of a page included as a template for all other pages: <?php $IP=$_SERVER['REMOTE_ADDR']; $DATE=date("j F Y g:ia"); $BROWSER=$_SERVER['HTTP_USER_AGENT']; $REFERER=$_SERVER['HTTP_REFERER']; mysql_connect("removed", "removed", "removed") or die(mysql_error()); mysql_select_db("removed"); mysql_query("INSERT INTO removed ( IP, DATE, BROWSER, REFERER ) VALUES ( '$IP', '$DATE', '$BROWSER', '$REFERER' )"); ?> PHP: Overall, my question is... WHAT am I doing WRONG?
I might add that the MySQL IP column in the table is a unique key, to avoid counting an IP more than once. In case somebody points that out