Current location: Hot Scripts Forums » General Community » Script Requests » PHP - Converting IP to Country


PHP - Converting IP to Country

Reply
  #1 (permalink)  
Old 05-11-07, 12:00 AM
cancer10 cancer10 is offline
Wannabe Coder
 
Join Date: Oct 2006
Location: India
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP - Converting IP to Country

PHP - Converting IP to Country

Hello,

Is there any function/pre-made scripts in php which can tell me the name of country based on IP?


For example: If I supply an IP 132.162.138.139 then the script would echo "India"

Thanx in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-11-07, 12:29 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Search Google: php ip2country
__________________
The toxic ZCE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-11-07, 12:31 AM
cancer10 cancer10 is offline
Wannabe Coder
 
Join Date: Oct 2006
Location: India
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Why would I come and post here if i would have found a proper solution on google?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-11-07, 01:09 AM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Moved to Script Requests.

Have a look at this class. From the looks of it, it does what you want.

Chris
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 05-11-07, 01:25 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
If you put detail in your requests and state what you have already tried (to show that you have tried something) you won't get "google" type answers.

We only see the information that you provide in your post. If you just put
Quote:
Is there any function/pre-made scripts in php which can tell me the name of country based on IP?
how do we know from that what you have already tried?

At least 60% of the questions seen on a forum like this are basic self research questions (look it up in the manual or search for it on the Internet) by people that don't seem to have the ability to look it up in a manual or search for it on the Internet. If there is no detail in your question to give us an idea of how you got to this point, you will probably get the most basic response that fits the level and detail of the question that was asked.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 05-11-07, 03:34 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
I just looked at the class Christian suggested, and it seems like it's connecting to a remote site to get the country information. If you don't want that, you can download a GeoLite City db yourself, and install it on your server:
http://www.maxmind.com/app/geolitecity

cheers
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 05-11-07, 06:42 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Quote:
Originally Posted by cancer10 View Post
Why would I come and post here if i would have found a proper solution on google?
What do you want me to do then, write one for you? That search turns up plenty of scripts.
__________________
The toxic ZCE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 05-16-08, 01:11 AM
IcySuMmeR IcySuMmeR is offline
New Member
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ip to cpuntry

Hi,

Does anyone know how to detect the country of the user? They are all located inside intranet and these users can be in the intranet of different countries. Since they are in the intranet their ip is something like 10.x.x.x. How to get the external ip address to make use of the GeoIp. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 05-16-08, 01:16 AM
cancer10 cancer10 is offline
Wannabe Coder
 
Join Date: Oct 2006
Location: India
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Keith View Post
What do you want me to do then, write one for you? That search turns up plenty of scripts.
You dont like reading post properly, do you?

I asked
Quote:
Is there any function/pre-made scripts
which means, "Do you know any function/pre-made scripts that does this thing"

Gottcha??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 05-16-08, 03:39 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
He read properly. What he's trying to say is that you didn't search well enough. Because if you do search for "ip2country", you WILL find functions/pre-made scripts...

If you still need help, look at Mab's post above first.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IP Address Search Engine Using AJAX and PHP TheJohnDoe2005 General Advertisements 0 01-18-06 09:11 PM
Display vistor IP, Browser, OS, Hostname, Country Nubier General HotScripts Site Discussion 0 09-11-05 12:19 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
php and ip address spidadesign PHP 0 05-16-05 06:05 PM
Converting My/SQL 'DATETIME' to PHP... giropets PHP 1 10-20-03 09:09 PM


All times are GMT -5. The time now is 12:29 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.