Jump to content

stan003

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by stan003

  1. HI, I have some code that obtains the ip address of the visitor and then looks up their ip address, a copy of the code is below: function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } function IPtoLatLng($ip) { $latlngValue=array(); $dom = new DOMDocument(); $ipcheck = ip2long($ip); if($ipcheck == -1 || $ipcheck === false){ echo "ERROR: INVALID IP"; exit; } else $uri = "http://api.hostip.info/?ip=$ip&position=true"; No what i want to do is swap the GetRealIp for a php variable, however when i write the code like this: $ip = "$ip"; function IPtoLatLng($ip) { $latlngValue=array(); $dom = new DOMDocument(); $ipcheck = ip2long($ip); if($ipcheck == -1 || $ipcheck === false){ echo "ERROR: INVALID IP"; exit; } else $uri = "http://api.hostip.info/?ip=$ip&position=true"; $dom->load($uri); $name=$dom->getElementsByTagNameNS('http://www.opengis.net/gml','name')->item(1)->nodeValue; $coordinates=$dom->getElementsByTagNameNS('http://www.opengis.net/gml','coordinates')->item(0)->nodeValue; $temp=explode(",",$coordinates); $latlngValue['LNG']=$temp[0]; $latlngValue['LAT']=$temp[1]; $latlngValue['NAME']=$name; return $latlngValue; } It returns Invalid IP, however no matter what i try i get the same response over and over again. Any suggestions would be appreciated. Thanks Stan
  2. hi sorry now i am confused, it's not possible to use that SELECT DATE('2012-02-22 3:40:00') as date; with the previous query you showed me is it? SO there fore would i just run a query with this code and then use that to populate the second query if that makes sense. Thanks
  3. Thanks for the reply, so i need to convert my date/time field to just date?
  4. Hello, I am trying to put together a mysql query that will return the number of visitors for four days ago, what i am trying to do is plot the last seven days visitors on a graph in the format of day seven, day six, etc and need to find away to get a count for each of those days. At the moment i am thinking about running various queries with each returning the results for a specific day. The code below is supposed to get the count of visitors four days ago. Not between now and four days ago but just for the 24 hour period which covers day 4. The current code just returns a value of 0. Any help would be appreciated. $result = mysql_query("SELECT ip FROM ip_stats WHERE date= date_sub(NOW(), interval 4 DAY)"); $num_rows = mysql_num_rows($result); echo "$num_rows";
  5. Hello, I know i can use server side code to capture a url etc, however i have a problem, i have a piece of Javascript that collects some information and passes it back to a php page which then proceses the information collected, which all works fine, on that php page i have the code to collect the refferring page, but obviously it just collects the details of the page it has come from which i already know. Is there anyway of using php to look back and get the page before that and any keywords that might have been used to get to that page, i know i could do this with javascript and include that information in the send, however the javascript is on another site and i really would prefer not having to change that if possible. I am not neccesarily looking for the solution but more if it is possible. Any advice would be appreciated. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.