$val) { $row[$key] = sqlite_escape_string($val); } if (!($country_id = check_if_exists($row[2]))) { // only insert country data if the country // was not previously encountered $res = safe_query("INSERT INTO country_data (cc_code_2, cc_code_3, country_name) VALUES('{$row[2]}', '{$row[3]}', '{$row[4]}')"); $country_id = sqlite_last_insert_rowid(sqlite_r); } // insert ip range entry safe_query("INSERT INTO ip_ranges (ip_start, ip_end, country_code) VALUES({$row[0]}, {$row[1]}, {$country_id})"); } fclose($fp); ?>