IP-numbers not found in database table ip2country
The comment from AyeshK led me to the right answer. I found this in the php manual:


  As pointed out by others, this function's return value is not
  consistent on 32 and 64-bit platforms.
  
  Your best bet for consistent behavior across 32/64-bit platforms (and
  Windows) is the lowest common denominator: force the return value of
  ip2long() into a signed 32-bit integer, e.g.:

var_dump(unpack('l', pack('l', ip2long('255.255.255.0'))));



And so I changed this row $ipl = ip2long($ip_address); into this $ipl = unpack('l', pack('l', ip2long($ip_address))); and now it works!

But if there is a better solution, please let me know.