php - Mysql Insert Error can not find the issue -
hi using code below, , have been through lots of times can not see why isn't working, think case of not being able see problem looking, grateful if else have , identitfy problem.
this error getting;
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'azur', 'antibes', '43.5624', '7.1278', '', '', 'europe/paris', 'eu', '', 'amadeu' @ line 6
and here code:
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 mastertable mysql_query("insert 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());
change following(similar) statements:
$country_code= $omni['country_code'];
to this:
$country_code= mysql_real_escape_string( $omni['country_code'] );
Comments
Post a Comment