public static function write_geolocation_data_to_db($geolocation_data, $source) { // create and check connection $link = CheckrouteDatabase::connect(); // write all entries in AS list to database foreach ($geolocation_data as $geolocation_entry) { $stmt = mysqli_prepare($link, "INSERT INTO IPRange_belongs_to_Country (ip_from, ip_to, country_code, assigning_rir, assigning_date, source) VALUES (?, ?, ?, ?, ?, ?)"); if ($stmt === false) { trigger_error('Error: Insert statement failed. ' . htmlspecialchars(mysqli_error($mysqli)), E_USER_ERROR); } $bind = mysqli_stmt_bind_param($stmt, "ssssss", $geolocation_entry['ip_from'], $geolocation_entry['ip_to'], $geolocation_entry['country'], $geolocation_entry['assigning_rir'], $geolocation_entry['assigning_date'], $source); if ($bind === false) { trigger_error('Error: Bind of parameters failed. ', E_USER_ERROR); } $exec = mysqli_stmt_execute($stmt); if ($exec === false) { print_r($geolocation_entry); trigger_error('Error: execution of statement failed. ' . htmlspecialchars(mysqli_stmt_error($stmt)), E_USER_ERROR); } } // close database connection CheckrouteDatabase::close($link); }