
Copy the following sample code into the app/Controllers/IP2Location_test.php file.
Define the database details like database name, username and password in the app/Config/Database.php file. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin Create the IP2Location DB11 Database table by using the following code. Simple and no extra cost required for IP location lookup. Supports IPv4 & IPv6 It works for all IP addresses including IPv4 and IPv6 in one database or API. All you need is your client’s IP address. Secondly, translate the IP address to an IP number in decimal format to speed up the database query. Here we are creating a database IP2Location with table ipcountry that consists of two IP address range records. IP2Location is a non-intrusive IP location lookup technology that retrieves geolocation information with no explicit permission required from users. Firstly, retrieve the IP address from the networking protocol or server-side variable of web server. #IP2LOCATION PHP MYSQL HOW TO#
The IP2Location Database table creation code can be found at the IP2Location FAQs page.īelow, we are going to show you an example of how to perform a MySQL query with the IP2Location DB11 Database in the CodeIgniter 4. IP2Location IP-Country Database DB1 provides a solution to determine the country of IP address in 3 simple steps.
In order to use the MySQL query, the IP2Location Database in CSV format needs to be downloaded and imported into the database. This new feature enables the user to get the geolocation data from the data table easily. IP2Location CodeIgniter 4 Library is fully integrated with supporting MySQL query in the latest version.