Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8071569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:43:46+00:00 2026-06-05T13:43:46+00:00

I use the Maxmind geoip database for retrieving a users country. We store all

  • 0

I use the Maxmind geoip database for retrieving a users country. We store all login attempts in mysql and often people login with different ip’s. This is not an issue if the ip’s are from the same country but if the password is shared on the boards you’ll see all sort of countries using it.

I now use this for retrieving the country and ip:

$ipaddress = (long2ip($row['ip']));
$country_name = geoip_country_name_by_addr($gi, "$ipaddress");
$country_iso =  geoip_country_code_by_addr($gi, "$ipaddress");

and then count the number of distinct ip addresses:

$count_ip = "SELECT distinct ip FROM members WHERE username='".$row['username']."'";
$result_ip = mysql_query($count_ip);
$ips = mysql_num_rows($result_ip);

if thats more then 1 i get a message.

But I would like to compare the Country codes for all ip addresses used by a username so i can see if the username is used by different countries and then give a message.

How would i do that? I have the array of ip’s and i need to first check the ip’s for country code and then see if it differs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:43:47+00:00Added an answer on June 5, 2026 at 1:43 pm

    Your query already returns all IP addresses, so you have to go through the result rows:

    $countries = array();
    while ($row = mysql_fetch_array($result_ip, MYSQL_NUM)) {
        $ipaddress = (long2ip($row[0]));
        $countries[geoip_country_name_by_addr($gi, "$ipaddress")] = true;
    }
    
    if (count($countries) > 1) {
        // more than one countries have been used to sign in
    }
    

    Btw, I’m assuming you add a date range to your query; otherwise you would negatively impact those who travel 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the MaxMind GeoLite Country database on the Google App
Is there an open-source alternative to MaxMind GeoIP Country/City that I can use for
recently i've used Maxmind geoip to locate country & city based on the ip.
I am planning to use Maxmind's DAT file to provide some basic geolocation capabilities
USE master GO DECLARE @DbName nvarchar(MAX) SET @DbName = N'DataBase' ALTER DATABASE @DbName SET
Use of java.net.URLConnection is asked about pretty often here, and the Oracle tutorial is
I want to use on my site a script that shows the user's country
Use case is to have a server connect to thousands of users email accounts
use case example I have a servlet that is receiving login requests. If a
Using Maxmind's GeoIP software, we can narrow down the LONG/LAT of an IP address

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.