0

I have a problem with the long2ip function. With data from $_SERVEUR or a string var it's working fine, giving me the correct IP. But with a string from the database the result is 0.0.0.0 .

<?php
$varip = '127.0.0.1';
p(ip2long($varip)); //display int(2130706433)
$varip2long = ip2long($varip);
p(long2ip($varip2long)); //string(9) "127.0.0.1"

p($longIpFromDb); //display string(10) "2130706433"
p(long2ip($longIpFromDb)); //display string(7) "0.0.0.0"
p(long2ip((int)$longIpFromDb)); //display string(7) "0.0.0.0"
?>

I'm running on 64bit server, mysql 5.0.11

1 Answers1

0

First make sure error_reporting is set to E_ALL error_reporting(E_ALL);.

As I suspect you are getting a Warning.

This result is very strange: 0.0.0.0. With invalid data I get 0.0.0.1.

https://3v4l.org/X7GQm

user5542121
  • 1,051
  • 12
  • 28