嗨,我正在使用下面的代码,并且已经通过了很多次,但看不出为什么这不起作用,我认为这只是无法看到问题的情况,所以我将不胜感激如果其他人可以查看并确定问题。
这是我得到的错误;
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near
'Azur', 'Antibes', '43.5624', '7.1278', '', '', 'Europe/Paris', 'EU', '', 'Amadeu'
at line 6
这是代码:
if (!isset($params['i'])) $params['i'] = '82.150.248.29';
$query = 'https://geoip.maxmind.com/e?' . http_build_query($params);
$omni_keys =
array(
'country_code',
'country_name',
'region_code',
'region_name',
'city_name',
'latitude',
'longitude',
'metro_code',
'area_code',
'time_zone',
'continent_code',
'postal_code',
'isp_name',
'organization_name',
'domain',
'as_number',
'netspeed',
'user_type',
'accuracy_radius',
'country_confidence',
'city_confidence',
'region_confidence',
'postal_confidence',
'error'
);
$curl = curl_init();
curl_setopt_array( $curl,
array(
CURLOPT_URL => $query,
CURLOPT_USERAGENT => 'MaxMind PHP Sample',
CURLOPT_RETURNTRANSFER => true
)
);
$resp = curl_exec($curl);
if (curl_errno($curl)) {
throw new Exception('GeoIP Request Failed');
}
$omni_values = str_getcsv($resp);
$omni = array_combine( $omni_keys, $omni_values);
//print_r($omni_values);
$country_code= $omni['country_code'];
$country_name= $omni['country_name'];
$region_code= $omni['region_code'];
$region_name= $omni['region_name'];
$city_name= $omni['city_name'];
$latitude= $omni['latitude'];
$longitude= $omni['longitude'];
$metro_code= $omni['metro_code'];
$area_code= $omni['area_code'];
$time_zone= $omni['time_zone'];
$continent_code= $omni['continent_code'];
$postal_code= $omni['postal_code'];
$isp_name= $omni['isp_name'];
$organization_name= $omni['organization_name'];
$domain= $omni['domain'];
$as_number= $omni['as_number'];
$netspeed= $omni['netspeed'];
$user_type= $omni['user_type'];
$accuracy_radius= $omni['accuracy_radius'];
$country_confidence= $omni['country_confidence'];
$city_confidence = $omni['city_confidence'];
$region_confidence= $omni['region_confidence'];
$postal_confidence= $omni['postal_confidence'];
$error= $omni['error'];
//Insert to MasterTable
mysql_query("INSERT INTO mastertable
(country_code, country_name, region_code, region_name, city_name, latitude, longitude, metro_code, area_code, time_zone, continent, postal_code, isp_name, organisation, domain_name, as_number, netspeed, user_type, accuracy_radius, country_confidence_factor, city_confidence_factor, region_confidence_factor, postal_code_confidence_factor, error)
VALUES
('$country_code', '$country_name', '$region_code', '$region_name', '$city_name', '$latitude', '$longitude', '$metro_code', '$area_code', '$time_zone', '$continent_code', '$postal_code', '$isp_name', '$organization_name', '$domain', '$as_number', '$netspeed', '$user_type', '$accuracy_radius', '$country_confidence', '$city_confidence', '$region_confidence', '$postal_confidence', '$error' ) ")
or die(mysql_error());