php - Splitting an IP Address Range, IP addresses stop after 210937 records -


i have database of ip ranges , using code below split range in individual ip addresses. works fine until 210937 records code stops spilitting ip range , starts inserting 0.0.0.0.

i have tried removing ip addresses still stops @ same point though ip address different.

 ($ip = ip2long($ip1); $ip<=ip2long($ip2); $ip++)  {  $lip = long2ip($ip); 

any suggestions appreciated.

ok here full code minus db connection.

  $query1 = "select * masteriplist";   $result = mysql_query($query1);   while($row = mysql_fetch_array($result))   {      $ipe = $row['ip_end_range'];    $ips = $row['ip_start_range'];     $ip1 = "$ips";    $ip2 = "$ipe";      ($ip = ip2long($ip1); $ip<=ip2long($ip2); $ip++)     {     $lip = long2ip($ip);       mysql_query("insert ip_master (ip) values ('$lip')")      or die(mysql_error());        }      } 

ok debugging code returned following

array(24) {    ["id"]=> string(2) "50"    ["ip_address"]=> string(12) "85.119.25.27"   ["ip_start_range"]=> string(0) ""   ["ip_end_range"]=> string(0) ""   ... } 

it looks you're processing single ip address instead of range; dealing both done this:

if ($row['ip_start_range'] == '' || $row['ip_end_range'] == '') {     $ip1 = $ip2 = $row['ip_address']; } else {     $ip1 = $row['ip_start_range'];     $ip2 = $row['ip_end_range']; } 

also, make more efficient moving ip2long calls outside of loop:

$start = ip2long($ip1); $stop = ip2long($ip2);  ($ip = $start; $ip <= $stop; $ip++) {   // ... } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -