0

hi guys i need to get this json data into my db so i have allready collected the details of another structure from the same site using a script similar to the one below but that was only 8 items long, this behaves as if it worked but nothing happens to the table in question heres the json:

[{"country":"Sri Lanka","countryCode":"LK"},{"country":"Syria","countryCode":"SY"},{"country":"Kenya","countryCode":"KE"},{"country":"Cambodia","countryCode":"KH"},{"country":"Mongolia","countryCode":"MN"},{"country":"Senegal","countryCode":"SN"},{"country":"Jordan","countryCode":"JO"},{"country":"Sweden","countryCode":"SE"},{"country":"United Kingdom","countryCode":"GB"},{"country":"Austria","countryCode":"AT"},{"country":"Israel","countryCode":"IL"},{"country":"Paraguay","countryCode":"PY"},{"country":"Jamaica","countryCode":"JM"},{"country":"Mexico","countryCode":"MX"},{"country":"Chile","countryCode":"CL"},{"country":"Canada","countryCode":"CA"},{"country":"Bulgaria","countryCode":"BG"},{"country":"Monaco","countryCode":"MC"},{"country":"Puerto Rico","countryCode":"PR"},{"country":"Lebanon","countryCode":"LB"},{"country":"Ecuador","countryCode":"EC"},{"country":"Palau","countryCode":"PW"},{"country":"Guam","countryCode":"GU"},{"country":"Macedonia","countryCode":"MK"},{"country":"Reunion","countryCode":"RE"},{"country":"Botswana","countryCode":"BW"},{"country":"Libya","countryCode":"LY"},{"country":"Togo","countryCode":"TG"},{"country":"Thailand","countryCode":"TH"},{"country":"Malaysia","countryCode":"MY"},{"country":"Spain","countryCode":"ES"},{"country":"Denmark","countryCode":"DK"},{"country":"Dominican Republic","countryCode":"DO"},{"country":"Belize","countryCode":"BZ"},{"country":"Nicaragua","countryCode":"NI"},{"country":"Venezuela","countryCode":"VE"},{"country":"Latvia","countryCode":"LV"},{"country":"Azerbaijan","countryCode":"AZ"},{"country":"Moldova","countryCode":"MD"},{"country":"United Arab Emirates","countryCode":"AE"},{"country":"Malta","countryCode":"MT"},{"country":"Swaziland","countryCode":"SZ"},{"country":"Yemen","countryCode":"YE"},{"country":"El Salvador","countryCode":"SV"},{"country":"Malawi","countryCode":"MW"},{"country":"French Guiana","countryCode":"GF"},{"country":"Bangladesh","countryCode":"BD"},{"country":"Liechtenstein","countryCode":"LI"},{"country":"San Marino","countryCode":"SM"},{"country":"Belarus","countryCode":"BY"},{"country":"Mozambique","countryCode":"MZ"},{"country":"Iran","countryCode":"IR"},{"country":"Pakistan","countryCode":"PK"},{"country":"Russia","countryCode":"RU"},{"country":"Mauritius","countryCode":"MU"},{"country":"Taiwan","countryCode":"TW"},{"country":"Portugal","countryCode":"PT"},{"country":"Nigeria","countryCode":"NG"},{"country":"Greece","countryCode":"GR"},{"country":"Switzerland","countryCode":"CH"},{"country":"Kuwait","countryCode":"KW"},{"country":"Luxembourg","countryCode":"LU"},{"country":"Czech Republic","countryCode":"CZ"},{"country":"Croatia","countryCode":"HR"},{"country":"Argentina","countryCode":"AR"},{"country":"Egypt","countryCode":"EG"},{"country":"Costa Rica","countryCode":"CR"},{"country":"United States","countryCode":"US"},{"country":"Lithuania","countryCode":"LT"},{"country":"Kazakhstan","countryCode":"KZ"},{"country":"Serbia","countryCode":"RS"},{"country":"Estonia","countryCode":"EE"},{"country":"Singapore","countryCode":"SG"},{"country":"Micronesia","countryCode":"FM"},{"country":"Albania","countryCode":"AL"},{"country":"Mali","countryCode":"ML"},{"country":"Uganda","countryCode":"UG"},{"country":"South Africa","countryCode":"ZA"},{"country":"Myanmar","countryCode":"MM"},{"country":"Australia","countryCode":"AU"},{"country":"Fiji","countryCode":"FJ"},{"country":"Italy","countryCode":"IT"},{"country":"Andorra","countryCode":"AD"},{"country":"Norway","countryCode":"NO"},{"country":"Brazil","countryCode":"BR"},{"country":"Uruguay","countryCode":"UY"},{"country":"Guatemala","countryCode":"GT"},{"country":"French Polynesia","countryCode":"PF"},{"country":"Seychelles","countryCode":"SC"},{"country":"Barbados","countryCode":"BB"},{"country":"Montenegro","countryCode":"ME"},{"country":"Laos","countryCode":"LA"},{"country":"Cook Islands","countryCode":"CK"},{"country":"Cayman Islands","countryCode":"KY"},{"country":"Gabon","countryCode":"GA"},{"country":"Saudi Arabia","countryCode":"SA"},{"country":"Vietnam","countryCode":"VN"},{"country":"Philippines","countryCode":"PH"},{"country":"South Korea","countryCode":"KR"},{"country":"Japan","countryCode":"JP"},{"country":"Vanuatu","countryCode":"VU"},{"country":"New Zealand","countryCode":"NZ"},{"country":"Tunisia","countryCode":"TN"},{"country":"Ireland","countryCode":"IE"},{"country":"Slovenia","countryCode":"SI"},{"country":"Suriname","countryCode":"SR"},{"country":"Finland","countryCode":"FI"},{"country":"Aruba","countryCode":"AW"},{"country":"Nepal","countryCode":"NP"},{"country":"Faroe Islands","countryCode":"FO"},{"country":"Sudan","countryCode":"SD"},{"country":"Indonesia","countryCode":"ID"},{"country":"China","countryCode":"CN"},{"country":"Maldives","countryCode":"MV"},{"country":"Uzbekistan","countryCode":"UZ"},{"country":"Hong Kong","countryCode":"HK"},{"country":"Algeria","countryCode":"DZ"},{"country":"Germany","countryCode":"DE"},{"country":"Oman","countryCode":"OM"},{"country":"France","countryCode":"FR"},{"country":"Slovakia","countryCode":"SK"},{"country":"Poland","countryCode":"PL"},{"country":"Bahamas","countryCode":"BS"},{"country":"Guadeloupe","countryCode":"GP"},{"country":"Colombia","countryCode":"CO"},{"country":"Bolivia","countryCode":"BO"},{"country":"Ukraine","countryCode":"UA"},{"country":"Netherlands Antilles","countryCode":"AN"},{"country":"Tonga","countryCode":"TO"},{"country":"Georgia","countryCode":"GE"},{"country":"Ethiopia","countryCode":"ET"},{"country":"Bermuda","countryCode":"BM"},{"country":"Cyprus","countryCode":"CY"},{"country":"Gambia","countryCode":"GM"},{"country":"Morocco","countryCode":"MA"},{"country":"Hungary","countryCode":"HU"},{"country":"Honduras","countryCode":"HN"},{"country":"Peru","countryCode":"PE"},{"country":"Romania","countryCode":"RO"},{"country":"Armenia","countryCode":"AM"},{"country":"New Caledonia","countryCode":"NC"},{"country":"Zambia","countryCode":"ZM"},{"country":"India","countryCode":"IN"},{"country":"Tanzania","countryCode":"TZ"},{"country":"Netherlands","countryCode":"NL"},{"country":"Belgium","countryCode":"BE"},{"country":"Turkey","countryCode":"TR"},{"country":"Namibia","countryCode":"NA"},{"country":"Grenada","countryCode":"GD"},{"country":"Qatar","countryCode":"QA"},{"country":"Iceland","countryCode":"IS"},{"country":"Bahrain","countryCode":"BH"},{"country":"Zimbabwe","countryCode":"ZW"},{"country":"Gibraltar","countryCode":"GI"},{"country":"Cameroon","countryCode":"CM"}]

then this is what the array looks like:

array(155) 
{ [0]=> array(2) { ["country"]=> string(9) "Sri Lanka" ["countryCode"]=> string(2) "LK" }
 [1]=> array(2) { ["country"]=> string(5) "Syria" ["countryCode"]=> string(2) "SY" } 
[2]=> array(2) { ["country"]=> string(5) "Kenya" ["countryCode"]=> string(2) "KE" } 
[3]=> array(2) { ["country"]=> string(8) "Cambodia" ["countryCode"]=> string(2) "KH" } 
[4]=> array(2) { ["country"]=> string(8) "Mongolia" ["countryCode"]=> string(2) "MN" }
  [5]=> array(2) { ["country"]=> string(7) "Senegal" ["countryCode"]=> string(2) "SN" }
  [6]=> array(2) { ["country"]=> string(6) "Jordan" ["countryCode"]=> string(2) "JO" }
 [7]=> array(2) { ["country"]=> string(6) "Sweden" ["countryCode"]=> string(2) "SE" } 
[8]=> array(2) { ["country"]=> string(14) "United Kingdom" ["countryCode"]=> string(2) "GB" }
 [9]=> array(2) { ["country"]=> string(7) "Austria" ["countryCode"]=> string(2) "AT" } [10]=> array(2) { ["country"]=> string(6) "Israel" ["countryCode"]=> string(2) "IL" } [11]=> array(2) { ["country"]=> string(8) "Paraguay" ["countryCode"]=> string(2) "PY" } [12]=> array(2) { ["country"]=> string(7) "Jamaica" ["countryCode"]=> string(2) "JM" } [13]=> array(2) { ["country"]=> string(6) "Mexico" ["countryCode"]=> string(2) "MX" } [14]=> array(2) { ["country"]=> string(5) "Chile" ["countryCode"]=> string(2) "CL" } [15]=> array(2) { ["country"]=> string(6) "Canada" ["countryCode"]=> string(2) "CA" } [16]=> array(2) { ["country"]=> string(8) "Bulgaria" ["countryCode"]=> string(2) "BG" } [17]=> array(2) { ["country"]=> string(6) "Monaco" ["countryCode"]=> string(2) "MC" } [18]=> array(2) { ["country"]=> string(11) "Puerto Rico" ["countryCode"]=> string(2) "PR" } [19]=> array(2) { ["country"]=> string(7) "Lebanon" ["countryCode"]=> string(2) "LB" } [20]=> array(2) { ["country"]=> string(7) "Ecuador" ["countryCode"]=> string(2) "EC" } [21]=> array(2) { ["country"]=> string(5) "Palau" ["countryCode"]=> string(2) "PW" } [22]=> array(2) { ["country"]=> string(4) "Guam" ["countryCode"]=> string(2) "GU" } [23]=> array(2) { ["country"]=> string(9) "Macedonia" ["countryCode"]=> string(2) "MK" } [24]=> array(2) { ["country"]=> string(7) "Reunion" ["countryCode"]=> string(2) "RE" } [25]=> array(2) { ["country"]=> string(8) "Botswana" ["countryCode"]=> string(2) "BW" } [26]=> array(2) { ["country"]=> string(5) "Libya" ["countryCode"]=> string(2) "LY" } [27]=> array(2) { ["country"]=> string(4) "Togo" ["countryCode"]=> string(2) "TG" } [28]=> array(2) { ["country"]=> string(8) "Thailand" ["countryCode"]=> string(2) "TH" } [29]=> array(2) { ["country"]=> string(8) "Malaysia" ["countryCode"]=> string(2) "MY" } [30]=> array(2) { ["country"]=> string(5) "Spain" ["countryCode"]=> string(2) "ES" } [31]=> array(2) { ["country"]=> string(7) "Denmark" ["countryCode"]=> string(2) "DK" } [32]=> array(2) { ["country"]=> string(18) "Dominican Republic" ["countryCode"]=> string(2) "DO" } [33]=> array(2) { ["country"]=> string(6) "Belize" ["countryCode"]=> string(2) "BZ" } [34]=> array(2) { ["country"]=> string(9) "Nicaragua" ["countryCode"]=> string(2) "NI" } [35]=> array(2) { ["country"]=> string(9) "Venezuela" ["countryCode"]=> string(2) "VE" } [36]=> array(2) { ["country"]=> string(6) "Latvia" ["countryCode"]=> string(2) "LV" } [37]=> array(2) { ["country"]=> string(10) "Azerbaijan" ["countryCode"]=> string(2) "AZ" } [38]=> array(2) { ["country"]=> string(7) "Moldova" ["countryCode"]=> string(2) "MD" } [39]=> array(2) { ["country"]=> string(20) "United Arab Emirates" ["countryCode"]=> string(2) "AE" } [40]=> array(2) { ["country"]=> string(5) "Malta" ["countryCode"]=> string(2) "MT" } [41]=> array(2) { ["country"]=> string(9) "Swaziland" ["countryCode"]=> string(2) "SZ" } [42]=> array(2) { ["country"]=> string(5) "Yemen" ["countryCode"]=> string(2) "YE" } [43]=> array(2) { ["country"]=> string(11) "El Salvador" ["countryCode"]=> string(2) "SV" } [44]=> array(2) { ["country"]=> string(6) "Malawi" ["countryCode"]=> string(2) "MW" } [45]=> array(2) { ["country"]=> string(13) "French Guiana" ["countryCode"]=> string(2) "GF" } [46]=> array(2) { ["country"]=> string(10) "Bangladesh" ["countryCode"]=> string(2) "BD" } [47]=> array(2) { ["country"]=> string(13) "Liechtenstein" ["countryCode"]=> string(2) "LI" } [48]=> array(2) { ["country"]=> string(10) "San Marino" ["countryCode"]=> string(2) "SM" } [49]=> array(2) { ["country"]=> string(7) "Belarus" ["countryCode"]=> string(2) "BY" } [50]=> array(2) { ["country"]=> string(10) "Mozambique" ["countryCode"]=> string(2) "MZ" } [51]=> array(2) { ["country"]=> string(4) "Iran" ["countryCode"]=> string(2) "IR" } [52]=> array(2) { ["country"]=> string(8) "Pakistan" ["countryCode"]=> string(2) "PK" } [53]=> array(2) { ["country"]=> string(6) "Russia" ["countryCode"]=> string(2) "RU" } [54]=> array(2) { ["country"]=> string(9) "Mauritius" ["countryCode"]=> string(2) "MU" } [55]=> array(2) { ["country"]=> string(6) "Taiwan" ["countryCode"]=> string(2) "TW" } [56]=> array(2) { ["country"]=> string(8) "Portugal" ["countryCode"]=> string(2) "PT" } [57]=> array(2) { ["country"]=> string(7) "Nigeria" ["countryCode"]=> string(2) "NG" } [58]=> array(2) { ["country"]=> string(6) "Greece" ["countryCode"]=> string(2) "GR" } [59]=> array(2) { ["country"]=> string(11) "Switzerland" ["countryCode"]=> string(2) "CH" } [60]=> array(2) { ["country"]=> string(6) "Kuwait" ["countryCode"]=> string(2) "KW" } [61]=> array(2) { ["country"]=> string(10) "Luxembourg" ["countryCode"]=> string(2) "LU" } [62]=> array(2) { ["country"]=> string(14) "Czech Republic" ["countryCode"]=> string(2) "CZ" } [63]=> array(2) { ["country"]=> string(7) "Croatia" ["countryCode"]=> string(2) "HR" } [64]=> array(2) { ["country"]=> string(9) "Argentina" ["countryCode"]=> string(2) "AR" } [65]=> array(2) { ["country"]=> string(5) "Egypt" ["countryCode"]=> string(2) "EG" } [66]=> array(2) { ["country"]=> string(10) "Costa Rica" ["countryCode"]=> string(2) "CR" } [67]=> array(2) { ["country"]=> string(13) "United States" ["countryCode"]=> string(2) "US" } [68]=> array(2) { ["country"]=> string(9) "Lithuania" ["countryCode"]=> string(2) "LT" } [69]=> array(2) { ["country"]=> string(10) "Kazakhstan" ["countryCode"]=> string(2) "KZ" } [70]=> array(2) { ["country"]=> string(6) "Serbia" ["countryCode"]=> string(2) "RS" } [71]=> array(2) { ["country"]=> string(7) "Estonia" ["countryCode"]=> string(2) "EE" } [72]=> array(2) { ["country"]=> string(9) "Singapore" ["countryCode"]=> string(2) "SG" } [73]=> array(2) { ["country"]=> string(10) "Micronesia" ["countryCode"]=> string(2) "FM" } [74]=> array(2) { ["country"]=> string(7) "Albania" ["countryCode"]=> string(2) "AL" } [75]=> array(2) { ["country"]=> string(4) "Mali" ["countryCode"]=> string(2) "ML" } [76]=> array(2) { ["country"]=> string(6) "Uganda" ["countryCode"]=> string(2) "UG" } [77]=> array(2) { ["country"]=> string(12) "South Africa" ["countryCode"]=> string(2) "ZA" } [78]=> array(2) { ["country"]=> string(7) "Myanmar" ["countryCode"]=> string(2) "MM" } [79]=> array(2) { ["country"]=> string(9) "Australia" ["countryCode"]=> string(2) "AU" } [80]=> array(2) { ["country"]=> string(4) "Fiji" ["countryCode"]=> string(2) "FJ" } [81]=> array(2) { ["country"]=> string(5) "Italy" ["countryCode"]=> string(2) "IT" } [82]=> array(2) { ["country"]=> string(7) "Andorra" ["countryCode"]=> string(2) "AD" } [83]=> array(2) { ["country"]=> string(6) "Norway" ["countryCode"]=> string(2) "NO" } [84]=> array(2) { ["country"]=> string(6) "Brazil" ["countryCode"]=> string(2) "BR" } [85]=> array(2) { ["country"]=> string(7) "Uruguay" ["countryCode"]=> string(2) "UY" } [86]=> array(2) { ["country"]=> string(9) "Guatemala" ["countryCode"]=> string(2) "GT" } [87]=> array(2) { ["country"]=> string(16) "French Polynesia" ["countryCode"]=> string(2) "PF" } [88]=> array(2) { ["country"]=> string(10) "Seychelles" ["countryCode"]=> string(2) "SC" } [89]=> array(2) { ["country"]=> string(8) "Barbados" ["countryCode"]=> string(2) "BB" } [90]=> array(2) { ["country"]=> string(10) "Montenegro" ["countryCode"]=> string(2) "ME" } [91]=> array(2) { ["country"]=> string(4) "Laos" ["countryCode"]=> string(2) "LA" } [92]=> array(2) { ["country"]=> string(12) "Cook Islands" ["countryCode"]=> string(2) "CK" } [93]=> array(2) { ["country"]=> string(14) "Cayman Islands" ["countryCode"]=> string(2) "KY" } [94]=> array(2) { ["country"]=> string(5) "Gabon" ["countryCode"]=> string(2) "GA" } [95]=> array(2) { ["country"]=> string(12) "Saudi Arabia" ["countryCode"]=> string(2) "SA" } [96]=> array(2) { ["country"]=> string(7) "Vietnam" ["countryCode"]=> string(2) "VN" } [97]=> array(2) { ["country"]=> string(11) "Philippines" ["countryCode"]=> string(2) "PH" } [98]=> array(2) { ["country"]=> string(11) "South Korea" ["countryCode"]=> string(2) "KR" } [99]=> array(2) { ["country"]=> string(5) "Japan" ["countryCode"]=> string(2) "JP" } [100]=> array(2) { ["country"]=> string(7) "Vanuatu" ["countryCode"]=> string(2) "VU" } [101]=> array(2) { ["country"]=> string(11) "New Zealand" ["countryCode"]=> string(2) "NZ" } [102]=> array(2) { ["country"]=> string(7) "Tunisia" ["countryCode"]=> string(2) "TN" } [103]=> array(2) { ["country"]=> string(7) "Ireland" ["countryCode"]=> string(2) "IE" } [104]=> array(2) { ["country"]=> string(8) "Slovenia" ["countryCode"]=> string(2) "SI" } [105]=> array(2) { ["country"]=> string(8) "Suriname" ["countryCode"]=> string(2) "SR" } [106]=> array(2) { ["country"]=> string(7) "Finland" ["countryCode"]=> string(2) "FI" } [107]=> array(2) { ["country"]=> string(5) "Aruba" ["countryCode"]=> string(2) "AW" } [108]=> array(2) { ["country"]=> string(5) "Nepal" ["countryCode"]=> string(2) "NP" } [109]=> array(2) { ["country"]=> string(13) "Faroe Islands" ["countryCode"]=> string(2) "FO" } [110]=> array(2) { ["country"]=> string(5) "Sudan" ["countryCode"]=> string(2) "SD" } [111]=> array(2) { ["country"]=> string(9) "Indonesia" ["countryCode"]=> string(2) "ID" } [112]=> array(2) { ["country"]=> string(5) "China" ["countryCode"]=> string(2) "CN" } [113]=> array(2) { ["country"]=> string(8) "Maldives" ["countryCode"]=> string(2) "MV" } [114]=> array(2) { ["country"]=> string(10) "Uzbekistan" ["countryCode"]=> string(2) "UZ" } [115]=> array(2) { ["country"]=> string(9) "Hong Kong" ["countryCode"]=> string(2) "HK" } [116]=> array(2) { ["country"]=> string(7) "Algeria" ["countryCode"]=> string(2) "DZ" } [117]=> array(2) { ["country"]=> string(7) "Germany" ["countryCode"]=> string(2) "DE" } [118]=> array(2) { ["country"]=> string(4) "Oman" ["countryCode"]=> string(2) "OM" } [119]=> array(2) { ["country"]=> string(6) "France" ["countryCode"]=> string(2) "FR" } [120]=> array(2) { ["country"]=> string(8) "Slovakia" ["countryCode"]=> string(2) "SK" } [121]=> array(2) { ["country"]=> string(6) "Poland" ["countryCode"]=> string(2) "PL" } [122]=> array(2) { ["country"]=> string(7) "Bahamas" ["countryCode"]=> string(2) "BS" } [123]=> array(2) { ["country"]=> string(10) "Guadeloupe" ["countryCode"]=> string(2) "GP" } [124]=> array(2) { ["country"]=> string(8) "Colombia" ["countryCode"]=> string(2) "CO" } [125]=> array(2) { ["country"]=> string(7) "Bolivia" ["countryCode"]=> string(2) "BO" } [126]=> array(2) { ["country"]=> string(7) "Ukraine" ["countryCode"]=> string(2) "UA" } [127]=> array(2) { ["country"]=> string(20) "Netherlands Antilles" ["countryCode"]=> string(2) "AN" } [128]=> array(2) { ["country"]=> string(5) "Tonga" ["countryCode"]=> string(2) "TO" } [129]=> array(2) { ["country"]=> string(7) "Georgia" ["countryCode"]=> string(2) "GE" } [130]=> array(2) { ["country"]=> string(8) "Ethiopia" ["countryCode"]=> string(2) "ET" } [131]=> array(2) { ["country"]=> string(7) "Bermuda" ["countryCode"]=> string(2) "BM" } [132]=> array(2) { ["country"]=> string(6) "Cyprus" ["countryCode"]=> string(2) "CY" } [133]=> array(2) { ["country"]=> string(6) "Gambia" ["countryCode"]=> string(2) "GM" } [134]=> array(2) { ["country"]=> string(7) "Morocco" ["countryCode"]=> string(2) "MA" } [135]=> array(2) { ["country"]=> string(7) "Hungary" ["countryCode"]=> string(2) "HU" } [136]=> array(2) { ["country"]=> string(8) "Honduras" ["countryCode"]=> string(2) "HN" } [137]=> array(2) { ["country"]=> string(4) "Peru" ["countryCode"]=> string(2) "PE" } [138]=> array(2) { ["country"]=> string(7) "Romania" ["countryCode"]=> string(2) "RO" } [139]=> array(2) { ["country"]=> string(7) "Armenia" ["countryCode"]=> string(2) "AM" } [140]=> array(2) { ["country"]=> string(13) "New Caledonia" ["countryCode"]=> string(2) "NC" } [141]=> array(2) { ["country"]=> string(6) "Zambia" ["countryCode"]=> string(2) "ZM" } [142]=> array(2) { ["country"]=> string(5) "India" ["countryCode"]=> string(2) "IN" } [143]=> array(2) { ["country"]=> string(8) "Tanzania" ["countryCode"]=> string(2) "TZ" } [144]=> array(2) { ["country"]=> string(11) "Netherlands" ["countryCode"]=> string(2) "NL" } [145]=> array(2) { ["country"]=> string(7) "Belgium" ["countryCode"]=> string(2) "BE" } [146]=> array(2) { ["country"]=> string(6) "Turkey" ["countryCode"]=> string(2) "TR" } [147]=> array(2) { ["country"]=> string(7) "Namibia" ["countryCode"]=> string(2) "NA" } [148]=> array(2) { ["country"]=> string(7) "Grenada" ["countryCode"]=> string(2) "GD" } [149]=> array(2) { ["country"]=> string(5) "Qatar" ["countryCode"]=> string(2) "QA" } [150]=> array(2) { ["country"]=> string(7) "Iceland" ["countryCode"]=> string(2) "IS" } [151]=> array(2) { ["country"]=> string(7) "Bahrain" ["countryCode"]=> string(2) "BH" } [152]=> array(2) { ["country"]=> string(8) "Zimbabwe" ["countryCode"]=> string(2) "ZW" } [153]=> array(2) { ["country"]=> string(9) "Gibraltar" ["countryCode"]=> string(2) "GI" } [154]=> array(2) { ["country"]=> string(8) "Cameroon" ["countryCode"]=> string(2) "CM" } } 

then this is the code used to convert to an array and insert into mysql but it doesn't get the data into mysql:

$ch = curl_init();
$timeout = 0;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdatar = curl_exec($ch);
curl_close($ch);
$object_array = json_decode($rawdatar,true);
foreach($object_array as $obj) {
    $country = $obj['country'];
    $countryCode = $obj['countryCode'];
    if($countryCode){
        $sql = "INSERT INTO `pt_country` (country,countrycode) VALUES ('$country','$countryCode')";
        database_queryModify($sql,$result);
    }
    else{
        echo "dint work";
    }
}

it behaves as if it should be doing somthing but when i check the sql table theres nothing what am i doing wrong with this? i know everything works upto the foreach and im only running this script once to get the data its not a regular request that someone could exploit i will be monitoring the data input

2 Answers 2

1

Did you check if the curl call works? No.

$rawdata = curl_exec($ch) or die(curl_error($ch));
                          ^^^^^^^^^^^^^^^^^^^^^^^^

Did you check if you actually get valid JSON data? after CURL completes? No

var_dump($rawdata);

Did you check if the JSON decode succeeds? No

var_dump($object_array);

Did you check if the INSERT query succeeds? No.

if (!database_queryModify($sql,$result)) { ... whatever your DB library's error message fetcher is };

As it stands now, your query is vulnerable to SQL injection, since you're inserting raw text provided by a remote site into your query strings. Nothing says the remote site can't be compromised and make $obj['country'] be little Bobby Tables

Sign up to request clarification or add additional context in comments.

1 Comment

yea thanks for the help, but ive tried everything you have typed and removed it as i know its working upto the mysql also i have allready run an identical script to this dealing with very similar data just less of it and it worked as expected
1

The length of the items should not be a problem for the database. I think there is an error but you can't see it.

Try to put error_reporting on and rerun the script. Add this code at the beginning of your script.

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

http://www.php.net/manual/en/function.error-reporting.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.