chrislim2888 / IP2Location-PHP-Module

This module is a PHP module that enables the user to find the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, mobile, usage types, address type, IAB category, etc that any IP address or host name originates from.
https://www.ip2location.com
MIT License
197 stars 69 forks source link

Not able to get CountryName, RegionName, CityName due to Warning: unpack() & Warning: fread() #21

Closed mrjethva closed 6 years ago

mrjethva commented 6 years ago

I am getting below warning message. Due to these, I am not able to get CountryName, RegionName, CityName & Zip code. Even i am using DB9 BIN database.

Warning: unpack(): Type C: not enough input, need 1, have 0 in D:\Xampp\htdocs\IP2Location.php on line 1118 Warning: fread(): Length parameter must be greater than 0 in D:\Xampp\htdocs\iplocation\IP2Location.php on line 1049

/*
    Default file I/O lookup
*/
$db = new \IP2Location\Database('./databases/IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('100.19.78.92', \IP2Location\Database::ALL);

I have placed the error screenshot in the attachment.

flimp-iplocation-error

ip2location commented 6 years ago

Can you try to reupload your .BIN file and make sure it's under binary mode? It seems like your .BIN file is corrupted.

mrjethva commented 6 years ago

Yes, .BIN file is corrupted, I have downloaded a fresh DB9 BIN database. and uploaded again .BIN file on a server. After reupload I checked the script and it was started working fine.