Would like to seek help in finding what is wrong with these codes. Before I added op_plan, op_reg, op_proj, audit_plan, audit_reg, audit_proj, it was perfectly working fine. But upon adding, db and table does not update. I tried looking for answers from this site, still no luck. Thanks in advance!
The error message is:
Notice: Undefined index: op_plan in updateplan
Notice: Undefined index: op_reg in updateplan
Notice: Undefined index: op_proj in updateplan
Notice: Undefined index: audit_plan in updateplan
Notice: Undefined index: audit_reg in updateplan
Notice: Undefined index: audit_proj in updateplan
updateplan
Your changes have been saved!
<?php
include ('db_config.php');
$alp_plan = $_POST['alp_plan'];
$alveo_plan = $_POST['alveo_plan'];
$avida_plan = $_POST['avida_plan'];
$amaia_plan = $_POST['amaia_plan'];
$bellavita_plan = $_POST['bellavita_plan'];
$vismin_plan = $_POST['vismin_plan'];
$finance_plan = $_POST['finance_plan'];
$finance_reg = $_POST['finance_reg'];
$finance_proj = $_POST['finance_proj'];
$hr_plan = $_POST['hr_plan'];
$hr_reg = $_POST['hr_reg'];
$hr_proj = $_POST['hr_proj'];
$bpaqa_plan = $_POST['bpaqa_plan'];
$bpaqa_reg = $_POST['bpaqa_reg'];
$bpaqa_proj = $_POST['bpaqa_proj'];
$isu_plan = $_POST['isu_plan'];
$isu_reg = $_POST['isu_reg'];
$isu_proj = $_POST['isu_proj'];
$bench_plan = $_POST['bench_plan'];
$bench_reg = $_POST['bench_reg'];
$bench_proj = $_POST['bench_proj'];
$admin_plan = $_POST['admin_plan'];
$admin_reg = $_POST['admin_reg'];
$admin_proj = $_POST['admin_proj'];
$inbound_plan = $_POST['inbound_plan'];
$inbound_reg = $_POST['inbound_reg'];
$inbound_proj = $_POST['inbound_proj'];
$records_plan = $_POST['records_plan'];
$records_reg = $_POST['records_reg'];
$records_proj = $_POST['records_proj'];
$alp_reg = $_POST['alp_reg'];
$alp_proj = $_POST['alp_proj'];
$alveo_reg = $_POST['alveo_reg'];
$alveo_proj = $_POST['alveo_proj'];
$avida_reg = $_POST['avida_reg'];
$avida_proj = $_POST['avida_proj'];
$amaia_reg = $_POST['amaia_reg'];
$amaia_proj = $_POST['amaia_proj'];
$bellavita_reg = $_POST['bellavita_reg'];
$bellavita_proj = $_POST['bellavita_proj'];
$vismin_reg = $_POST['vismin_reg'];
$vismin_proj = $_POST['vismin_proj'];
$op_plan = $_POST['op_plan'];
$op_reg = $_POST['op_reg'];
$op_proj = $_POST['op_proj'];
$audit_plan = $_POST['audit_plan'];
$audit_reg = $_POST['audit_reg'];
$audit_proj = $_POST['audit_proj'];
$remarks = mysqli_real_escape_string($con, $_POST['remarks']);
$year = $_POST['year'];
$sql = "UPDATE manpowerplan SET alp_plan = '$alp_plan', alveo_plan = '$alveo_plan', avida_plan = '$avida_plan', amaia_plan = '$amaia_plan', bellavita_plan = '$bellavita_plan', vismin_plan = '$vismin_plan', finance_plan = '$finance_plan', finance_reg = '$finance_reg', finance_proj = '$finance_proj', hr_plan = '$hr_plan', hr_reg = '$hr_reg', hr_proj = '$hr_proj', bpaqa_plan = '$bpaqa_plan', bpaqa_reg = '$bpaqa_reg', bpaqa_proj = '$bpaqa_proj', isu_plan = '$isu_plan', isu_reg = '$isu_reg', isu_proj = '$isu_proj', bench_plan = '$bench_plan', bench_reg = '$bench_reg', bench_proj = '$bench_proj', admin_plan = '$admin_plan', admin_reg = '$admin_reg', admin_proj = '$admin_proj', inbound_plan = '$inbound_plan', inbound_reg = '$inbound_reg', inbound_proj = '$inbound_proj', records_plan = '$records_plan', records_reg = '$records_reg', records_proj = '$records_proj', alp_reg = '$alp_reg', alp_proj = '$alp_proj', alveo_reg = '$alveo_reg', alveo_proj = '$alveo_proj', avida_reg = '$avida_reg', avida_proj = '$avida_proj', amaia_reg = '$amaia_reg', amaia_proj = '$amaia_proj', bellavita_reg = '$bellavita_reg', bellavita_proj = '$bellavita_proj', vismin_reg = '$vismin_reg', vismin_proj = '$vismin_proj', op_plan = '$op_plan', op_reg = '$op_reg', op_proj = '$op_proj', audit_plan = '$audit_plan', audit_reg = '$audit_reg', audit_proj = '$audit_proj', remarks = '$remarks' WHERE year = '$year'";
$query = mysqli_query($con, $sql);
if(!$query)
echo $sql;
else
echo "Your changes have been saved! " ;
?>
Those variable op_plan, op_reg, op_proj, audit_plan, audit_reg, audit_proj,
are undefined, you should add them to form to, after you add them to table and SQL query, now they $_POST doesn't get them and make them as 'undefined'.
please add the form Code so can how look.
I'm trying to get the calling code and the country name of my visitors.
Previously, I had a connection to the DB to get the calling code and country name that matches the one we got from CloudFlare, using
$_SERVER["HTTP_CF_IPCOUNTRY"];
and
$country_code=$_SERVER["HTTP_CF_IPCOUNTRY"];
$stmt = $pdo->query('SELECT short_name, calling_code from country WHERE iso2 LIKE "'.$country_code.'"');
$country = $stmt->fetch();
However, when traffic gets heavy, having many connections to the DB can be problematic. So I defined this array:
$countries = array();
$countries['AF'] = array("code"=>"AF","short_name"=>"Afghanistan","calling_code"=>"93");
$countries['AL'] = array("code"=>"AL","short_name"=>"Albania","calling_code"=>"355");
$countries['DZ'] = array("code"=>"DZ","short_name"=>"Algeria","calling_code"=>"213");
$countries['AS'] = array("code"=>"AS","short_name"=>"American Samoa","calling_code"=>"1");
$countries['AD'] = array("code"=>"AD","short_name"=>"Andorra","calling_code"=>"376");
$countries['AO'] = array("code"=>"AO","short_name"=>"Angola","calling_code"=>"244");
$countries['AI'] = array("code"=>"AI","short_name"=>"Anguilla","calling_code"=>"1");
$countries['AG'] = array("code"=>"AG","short_name"=>"Antigua","calling_code"=>"1");
$countries['AR'] = array("code"=>"AR","short_name"=>"Argentina","calling_code"=>"54");
$countries['AM'] = array("code"=>"AM","short_name"=>"Armenia","calling_code"=>"374");
$countries['AW'] = array("code"=>"AW","short_name"=>"Aruba","calling_code"=>"297");
$countries['AU'] = array("code"=>"AU","short_name"=>"Australia","calling_code"=>"61");
$countries['AT'] = array("code"=>"AT","short_name"=>"Austria","calling_code"=>"43");
$countries['AZ'] = array("code"=>"AZ","short_name"=>"Azerbaijan","calling_code"=>"994");
$countries['BH'] = array("code"=>"BH","short_name"=>"Bahrain","calling_code"=>"973");
$countries['BD'] = array("code"=>"BD","short_name"=>"Bangladesh","calling_code"=>"880");
$countries['BB'] = array("code"=>"BB","short_name"=>"Barbados","calling_code"=>"1");
$countries['BY'] = array("code"=>"BY","short_name"=>"Belarus","calling_code"=>"375");
$countries['BE'] = array("code"=>"BE","short_name"=>"Belgium","calling_code"=>"32");
$countries['BZ'] = array("code"=>"BZ","short_name"=>"Belize","calling_code"=>"501");
$countries['BJ'] = array("code"=>"BJ","short_name"=>"Benin","calling_code"=>"229");
$countries['BM'] = array("code"=>"BM","short_name"=>"Bermuda","calling_code"=>"1");
$countries['BT'] = array("code"=>"BT","short_name"=>"Bhutan","calling_code"=>"975");
$countries['BO'] = array("code"=>"BO","short_name"=>"Bolivia","calling_code"=>"591");
$countries['BA'] = array("code"=>"BA","short_name"=>"Bosnia and Herzegovina","calling_code"=>"387");
$countries['BW'] = array("code"=>"BW","short_name"=>"Botswana","calling_code"=>"267");
$countries['BR'] = array("code"=>"BR","short_name"=>"Brazil","calling_code"=>"55");
$countries['IO'] = array("code"=>"IO","short_name"=>"British Indian Ocean Territory","calling_code"=>"246");
$countries['VG'] = array("code"=>"VG","short_name"=>"British Virgin Islands","calling_code"=>"1");
$countries['BN'] = array("code"=>"BN","short_name"=>"Brunei","calling_code"=>"673");
$countries['BG'] = array("code"=>"BG","short_name"=>"Bulgaria","calling_code"=>"359");
$countries['BF'] = array("code"=>"BF","short_name"=>"Burkina Faso","calling_code"=>"226");
$countries['MM'] = array("code"=>"MM","short_name"=>"Burma Myanmar" ,"calling_code"=>"95");
$countries['BI'] = array("code"=>"BI","short_name"=>"Burundi","calling_code"=>"257");
$countries['KH'] = array("code"=>"KH","short_name"=>"Cambodia","calling_code"=>"855");
$countries['CM'] = array("code"=>"CM","short_name"=>"Cameroon","calling_code"=>"237");
$countries['CA'] = array("code"=>"CA","short_name"=>"Canada","calling_code"=>"1");
$countries['CV'] = array("code"=>"CV","short_name"=>"Cape Verde","calling_code"=>"238");
$countries['KY'] = array("code"=>"KY","short_name"=>"Cayman Islands","calling_code"=>"1");
$countries['CF'] = array("code"=>"CF","short_name"=>"Central African Republic","calling_code"=>"236");
$countries['TD'] = array("code"=>"TD","short_name"=>"Chad","calling_code"=>"235");
$countries['CL'] = array("code"=>"CL","short_name"=>"Chile","calling_code"=>"56");
$countries['CN'] = array("code"=>"CN","short_name"=>"China","calling_code"=>"86");
$countries['CO'] = array("code"=>"CO","short_name"=>"Colombia","calling_code"=>"57");
$countries['KM'] = array("code"=>"KM","short_name"=>"Comoros","calling_code"=>"269");
$countries['CK'] = array("code"=>"CK","short_name"=>"Cook Islands","calling_code"=>"682");
$countries['CR'] = array("code"=>"CR","short_name"=>"Costa Rica","calling_code"=>"506");
$countries['CI'] = array("code"=>"CI","short_name"=>"Côte d'Ivoire" ,"calling_code"=>"225");
$countries['HR'] = array("code"=>"HR","short_name"=>"Croatia","calling_code"=>"385");
$countries['CU'] = array("code"=>"CU","short_name"=>"Cuba","calling_code"=>"53");
$countries['CY'] = array("code"=>"CY","short_name"=>"Cyprus","calling_code"=>"357");
$countries['CZ'] = array("code"=>"CZ","short_name"=>"Czech Republic","calling_code"=>"420");
$countries['CD'] = array("code"=>"CD","short_name"=>"Democratic Republic of Congo","calling_code"=>"243");
$countries['DK'] = array("code"=>"DK","short_name"=>"Denmark","calling_code"=>"45");
$countries['DJ'] = array("code"=>"DJ","short_name"=>"Djibouti","calling_code"=>"253");
$countries['DM'] = array("code"=>"DM","short_name"=>"Dominica","calling_code"=>"1");
$countries['DO'] = array("code"=>"DO","short_name"=>"Dominican Republic","calling_code"=>"1");
$countries['EC'] = array("code"=>"EC","short_name"=>"Ecuador","calling_code"=>"593");
$countries['EG'] = array("code"=>"EG","short_name"=>"Egypt","calling_code"=>"20");
$countries['SV'] = array("code"=>"SV","short_name"=>"El Salvador","calling_code"=>"503");
$countries['GQ'] = array("code"=>"GQ","short_name"=>"Equatorial Guinea","calling_code"=>"240");
$countries['ER'] = array("code"=>"ER","short_name"=>"Eritrea","calling_code"=>"291");
$countries['EE'] = array("code"=>"EE","short_name"=>"Estonia","calling_code"=>"372");
$countries['ET'] = array("code"=>"ET","short_name"=>"Ethiopia","calling_code"=>"251");
$countries['FK'] = array("code"=>"FK","short_name"=>"Falkland Islands","calling_code"=>"500");
$countries['FO'] = array("code"=>"FO","short_name"=>"Faroe Islands","calling_code"=>"298");
$countries['FM'] = array("code"=>"FM","short_name"=>"Federated States of Micronesia","calling_code"=>"691");
$countries['FJ'] = array("code"=>"FJ","short_name"=>"Fiji","calling_code"=>"679");
$countries['FI'] = array("code"=>"FI","short_name"=>"Finland","calling_code"=>"358");
$countries['FR'] = array("code"=>"FR","short_name"=>"France","calling_code"=>"33");
$countries['GF'] = array("code"=>"GF","short_name"=>"French Guiana","calling_code"=>"594");
$countries['PF'] = array("code"=>"PF","short_name"=>"French Polynesia","calling_code"=>"689");
$countries['GA'] = array("code"=>"GA","short_name"=>"Gabon","calling_code"=>"241");
$countries['GE'] = array("code"=>"GE","short_name"=>"Georgia","calling_code"=>"995");
$countries['DE'] = array("code"=>"DE","short_name"=>"Germany","calling_code"=>"49");
$countries['GH'] = array("code"=>"GH","short_name"=>"Ghana","calling_code"=>"233");
$countries['GI'] = array("code"=>"GI","short_name"=>"Gibraltar","calling_code"=>"350");
$countries['GR'] = array("code"=>"GR","short_name"=>"Greece","calling_code"=>"30");
$countries['GL'] = array("code"=>"GL","short_name"=>"Greenland","calling_code"=>"299");
$countries['GD'] = array("code"=>"GD","short_name"=>"Grenada","calling_code"=>"1");
$countries['GP'] = array("code"=>"GP","short_name"=>"Guadeloupe","calling_code"=>"590");
$countries['GU'] = array("code"=>"GU","short_name"=>"Guam","calling_code"=>"1");
$countries['GT'] = array("code"=>"GT","short_name"=>"Guatemala","calling_code"=>"502");
$countries['GN'] = array("code"=>"GN","short_name"=>"Guinea","calling_code"=>"224");
$countries['GW'] = array("code"=>"GW","short_name"=>"Guinea-Bissau","calling_code"=>"245");
$countries['GY'] = array("code"=>"GY","short_name"=>"Guyana","calling_code"=>"592");
$countries['HT'] = array("code"=>"HT","short_name"=>"Haiti","calling_code"=>"509");
$countries['HN'] = array("code"=>"HN","short_name"=>"Honduras","calling_code"=>"504");
$countries['HK'] = array("code"=>"HK","short_name"=>"Hong Kong","calling_code"=>"852");
$countries['HU'] = array("code"=>"HU","short_name"=>"Hungary","calling_code"=>"36");
$countries['IS'] = array("code"=>"IS","short_name"=>"Iceland","calling_code"=>"354");
$countries['IN'] = array("code"=>"IN","short_name"=>"India","calling_code"=>"91");
$countries['ID'] = array("code"=>"ID","short_name"=>"Indonesia","calling_code"=>"62");
$countries['IR'] = array("code"=>"IR","short_name"=>"Iran","calling_code"=>"98");
$countries['IQ'] = array("code"=>"IQ","short_name"=>"Iraq","calling_code"=>"964");
$countries['IE'] = array("code"=>"IE","short_name"=>"Ireland","calling_code"=>"353");
$countries['IL'] = array("code"=>"IL","short_name"=>"Israel","calling_code"=>"972");
$countries['IT'] = array("code"=>"IT","short_name"=>"Italy","calling_code"=>"39");
$countries['JM'] = array("code"=>"JM","short_name"=>"Jamaica","calling_code"=>"1");
$countries['JP'] = array("code"=>"JP","short_name"=>"Japan","calling_code"=>"81");
$countries['JO'] = array("code"=>"JO","short_name"=>"Jordan","calling_code"=>"962");
$countries['KZ'] = array("code"=>"KZ","short_name"=>"Kazakhstan","calling_code"=>"7");
$countries['KE'] = array("code"=>"KE","short_name"=>"Kenya","calling_code"=>"254");
$countries['KI'] = array("code"=>"KI","short_name"=>"Kiribati","calling_code"=>"686");
$countries['XK'] = array("code"=>"XK","short_name"=>"Kosovo","calling_code"=>"381");
$countries['KW'] = array("code"=>"KW","short_name"=>"Kuwait","calling_code"=>"965");
$countries['KG'] = array("code"=>"KG","short_name"=>"Kyrgyzstan","calling_code"=>"996");
$countries['LA'] = array("code"=>"LA","short_name"=>"Laos","calling_code"=>"856");
$countries['LV'] = array("code"=>"LV","short_name"=>"Latvia","calling_code"=>"371");
$countries['LB'] = array("code"=>"LB","short_name"=>"Lebanon","calling_code"=>"961");
$countries['LS'] = array("code"=>"LS","short_name"=>"Lesotho","calling_code"=>"266");
$countries['LR'] = array("code"=>"LR","short_name"=>"Liberia","calling_code"=>"231");
$countries['LY'] = array("code"=>"LY","short_name"=>"Libya","calling_code"=>"218");
$countries['LI'] = array("code"=>"LI","short_name"=>"Liechtenstein","calling_code"=>"423");
$countries['LT'] = array("code"=>"LT","short_name"=>"Lithuania","calling_code"=>"370");
$countries['LU'] = array("code"=>"LU","short_name"=>"Luxembourg","calling_code"=>"352");
$countries['MO'] = array("code"=>"MO","short_name"=>"Macau","calling_code"=>"853");
$countries['MK'] = array("code"=>"MK","short_name"=>"Macedonia","calling_code"=>"389");
$countries['MG'] = array("code"=>"MG","short_name"=>"Madagascar","calling_code"=>"261");
$countries['MW'] = array("code"=>"MW","short_name"=>"Malawi","calling_code"=>"265");
$countries['MY'] = array("code"=>"MY","short_name"=>"Malaysia","calling_code"=>"60");
$countries['MV'] = array("code"=>"MV","short_name"=>"Maldives","calling_code"=>"960");
$countries['ML'] = array("code"=>"ML","short_name"=>"Mali","calling_code"=>"223");
$countries['MT'] = array("code"=>"MT","short_name"=>"Malta","calling_code"=>"356");
$countries['MH'] = array("code"=>"MH","short_name"=>"Marshall Islands","calling_code"=>"692");
$countries['MQ'] = array("code"=>"MQ","short_name"=>"Martinique","calling_code"=>"596");
$countries['MR'] = array("code"=>"MR","short_name"=>"Mauritania","calling_code"=>"222");
$countries['MU'] = array("code"=>"MU","short_name"=>"Mauritius","calling_code"=>"230");
$countries['YT'] = array("code"=>"YT","short_name"=>"Mayotte","calling_code"=>"262");
$countries['MX'] = array("code"=>"MX","short_name"=>"Mexico","calling_code"=>"52");
$countries['MD'] = array("code"=>"MD","short_name"=>"Moldova","calling_code"=>"373");
$countries['MC'] = array("code"=>"MC","short_name"=>"Monaco","calling_code"=>"377");
$countries['MN'] = array("code"=>"MN","short_name"=>"Mongolia","calling_code"=>"976");
$countries['ME'] = array("code"=>"ME","short_name"=>"Montenegro","calling_code"=>"382");
$countries['MS'] = array("code"=>"MS","short_name"=>"Montserrat","calling_code"=>"1");
$countries['MA'] = array("code"=>"MA","short_name"=>"Morocco","calling_code"=>"212");
$countries['MZ'] = array("code"=>"MZ","short_name"=>"Mozambique","calling_code"=>"258");
$countries['NA'] = array("code"=>"NA","short_name"=>"Namibia","calling_code"=>"264");
$countries['NR'] = array("code"=>"NR","short_name"=>"Nauru","calling_code"=>"674");
$countries['NP'] = array("code"=>"NP","short_name"=>"Nepal","calling_code"=>"977");
$countries['NL'] = array("code"=>"NL","short_name"=>"Netherlands","calling_code"=>"31");
$countries['AN'] = array("code"=>"AN","short_name"=>"Netherlands Antilles","calling_code"=>"599");
$countries['NC'] = array("code"=>"NC","short_name"=>"New Caledonia","calling_code"=>"687");
$countries['NZ'] = array("code"=>"NZ","short_name"=>"New Zealand","calling_code"=>"64");
$countries['NI'] = array("code"=>"NI","short_name"=>"Nicaragua","calling_code"=>"505");
$countries['NE'] = array("code"=>"NE","short_name"=>"Niger","calling_code"=>"227");
$countries['NG'] = array("code"=>"NG","short_name"=>"Nigeria","calling_code"=>"234");
$countries['NU'] = array("code"=>"NU","short_name"=>"Niue","calling_code"=>"683");
$countries['NF'] = array("code"=>"NF","short_name"=>"Norfolk Island","calling_code"=>"672");
$countries['KP'] = array("code"=>"KP","short_name"=>"North Korea","calling_code"=>"850");
$countries['MP'] = array("code"=>"MP","short_name"=>"Northern Mariana Islands","calling_code"=>"1");
$countries['NO'] = array("code"=>"NO","short_name"=>"Norway","calling_code"=>"47");
$countries['OM'] = array("code"=>"OM","short_name"=>"Oman","calling_code"=>"968");
$countries['PK'] = array("code"=>"PK","short_name"=>"Pakistan","calling_code"=>"92");
$countries['PW'] = array("code"=>"PW","short_name"=>"Palau","calling_code"=>"680");
$countries['PS'] = array("code"=>"PS","short_name"=>"Palestine","calling_code"=>"970");
$countries['PA'] = array("code"=>"PA","short_name"=>"Panama","calling_code"=>"507");
$countries['PG'] = array("code"=>"PG","short_name"=>"Papua New Guinea","calling_code"=>"675");
$countries['PY'] = array("code"=>"PY","short_name"=>"Paraguay","calling_code"=>"595");
$countries['PE'] = array("code"=>"PE","short_name"=>"Peru","calling_code"=>"51");
$countries['PH'] = array("code"=>"PH","short_name"=>"Philippines","calling_code"=>"63");
$countries['PL'] = array("code"=>"PL","short_name"=>"Poland","calling_code"=>"48");
$countries['PT'] = array("code"=>"PT","short_name"=>"Portugal","calling_code"=>"351");
$countries['PR'] = array("code"=>"PR","short_name"=>"Puerto Rico","calling_code"=>"1");
$countries['QA'] = array("code"=>"QA","short_name"=>"Qatar","calling_code"=>"974");
$countries['CG'] = array("code"=>"CG","short_name"=>"Republic of the Congo","calling_code"=>"242");
$countries['RE'] = array("code"=>"RE","short_name"=>"Réunion" ,"calling_code"=>"262");
$countries['RO'] = array("code"=>"RO","short_name"=>"Romania","calling_code"=>"40");
$countries['RU'] = array("code"=>"RU","short_name"=>"Russia","calling_code"=>"7");
$countries['RW'] = array("code"=>"RW","short_name"=>"Rwanda","calling_code"=>"250");
$countries['BL'] = array("code"=>"BL","short_name"=>"Saint Barthélemy" ,"calling_code"=>"590");
$countries['SH'] = array("code"=>"SH","short_name"=>"Saint Helena","calling_code"=>"290");
$countries['KN'] = array("code"=>"KN","short_name"=>"Saint Kitts and Nevis","calling_code"=>"1");
$countries['MF'] = array("code"=>"MF","short_name"=>"Saint Martin","calling_code"=>"590");
$countries['PM'] = array("code"=>"PM","short_name"=>"Saint Pierre and Miquelon","calling_code"=>"508");
$countries['VC'] = array("code"=>"VC","short_name"=>"Saint Vincent and the Grenadines","calling_code"=>"1");
$countries['WS'] = array("code"=>"WS","short_name"=>"Samoa","calling_code"=>"685");
$countries['SM'] = array("code"=>"SM","short_name"=>"San Marino","calling_code"=>"378");
$countries['ST'] = array("code"=>"ST","short_name"=>"São Tomé and Príncipe" ,"calling_code"=>"239");
$countries['SA'] = array("code"=>"SA","short_name"=>"Saudi Arabia","calling_code"=>"966");
$countries['SN'] = array("code"=>"SN","short_name"=>"Senegal","calling_code"=>"221");
$countries['RS'] = array("code"=>"RS","short_name"=>"Serbia","calling_code"=>"381");
$countries['SC'] = array("code"=>"SC","short_name"=>"Seychelles","calling_code"=>"248");
$countries['SL'] = array("code"=>"SL","short_name"=>"Sierra Leone","calling_code"=>"232");
$countries['SG'] = array("code"=>"SG","short_name"=>"Singapore","calling_code"=>"65");
$countries['SK'] = array("code"=>"SK","short_name"=>"Slovakia","calling_code"=>"421");
$countries['SI'] = array("code"=>"SI","short_name"=>"Slovenia","calling_code"=>"386");
$countries['SB'] = array("code"=>"SB","short_name"=>"Solomon Islands","calling_code"=>"677");
$countries['SO'] = array("code"=>"SO","short_name"=>"Somalia","calling_code"=>"252");
$countries['ZA'] = array("code"=>"ZA","short_name"=>"South Africa","calling_code"=>"27");
$countries['KR'] = array("code"=>"KR","short_name"=>"South Korea","calling_code"=>"82");
$countries['ES'] = array("code"=>"ES","short_name"=>"Spain","calling_code"=>"34");
$countries['LK'] = array("code"=>"LK","short_name"=>"Sri Lanka","calling_code"=>"94");
$countries['LC'] = array("code"=>"LC","short_name"=>"St. Lucia","calling_code"=>"1");
$countries['SD'] = array("code"=>"SD","short_name"=>"Sudan","calling_code"=>"249");
$countries['SR'] = array("code"=>"SR","short_name"=>"Surishort_name","calling_code"=>"597");
$countries['SZ'] = array("code"=>"SZ","short_name"=>"Swaziland","calling_code"=>"268");
$countries['SE'] = array("code"=>"SE","short_name"=>"Sweden","calling_code"=>"46");
$countries['CH'] = array("code"=>"CH","short_name"=>"Switzerland","calling_code"=>"41");
$countries['SY'] = array("code"=>"SY","short_name"=>"Syria","calling_code"=>"963");
$countries['TW'] = array("code"=>"TW","short_name"=>"Taiwan","calling_code"=>"886");
$countries['TJ'] = array("code"=>"TJ","short_name"=>"Tajikistan","calling_code"=>"992");
$countries['TZ'] = array("code"=>"TZ","short_name"=>"Tanzania","calling_code"=>"255");
$countries['TH'] = array("code"=>"TH","short_name"=>"Thailand","calling_code"=>"66");
$countries['BS'] = array("code"=>"BS","short_name"=>"The Bahamas","calling_code"=>"1");
$countries['GM'] = array("code"=>"GM","short_name"=>"The Gambia","calling_code"=>"220");
$countries['TL'] = array("code"=>"TL","short_name"=>"Timor-Leste","calling_code"=>"670");
$countries['TG'] = array("code"=>"TG","short_name"=>"Togo","calling_code"=>"228");
$countries['TK'] = array("code"=>"TK","short_name"=>"Tokelau","calling_code"=>"690");
$countries['TO'] = array("code"=>"TO","short_name"=>"Tonga","calling_code"=>"676");
$countries['TT'] = array("code"=>"TT","short_name"=>"Trinidad and Tobago","calling_code"=>"1");
$countries['TN'] = array("code"=>"TN","short_name"=>"Tunisia","calling_code"=>"216");
$countries['TR'] = array("code"=>"TR","short_name"=>"Turkey","calling_code"=>"90");
$countries['TM'] = array("code"=>"TM","short_name"=>"Turkmenistan","calling_code"=>"993");
$countries['TC'] = array("code"=>"TC","short_name"=>"Turks and Caicos Islands","calling_code"=>"1");
$countries['TV'] = array("code"=>"TV","short_name"=>"Tuvalu","calling_code"=>"688");
$countries['UG'] = array("code"=>"UG","short_name"=>"Uganda","calling_code"=>"256");
$countries['UA'] = array("code"=>"UA","short_name"=>"Ukraine","calling_code"=>"380");
$countries['AE'] = array("code"=>"AE","short_name"=>"United Arab Emirates","calling_code"=>"971");
$countries['GB'] = array("code"=>"GB","short_name"=>"United Kingdom","calling_code"=>"44");
$countries['US'] = array("code"=>"US","short_name"=>"United States","calling_code"=>"1");
$countries['UY'] = array("code"=>"UY","short_name"=>"Uruguay","calling_code"=>"598");
$countries['VI'] = array("code"=>"VI","short_name"=>"US Virgin Islands","calling_code"=>"1");
$countries['UZ'] = array("code"=>"UZ","short_name"=>"Uzbekistan","calling_code"=>"998");
$countries['VU'] = array("code"=>"VU","short_name"=>"Vanuatu","calling_code"=>"678");
$countries['VA'] = array("code"=>"VA","short_name"=>"Vatican City","calling_code"=>"39");
$countries['VE'] = array("code"=>"VE","short_name"=>"Venezuela","calling_code"=>"58");
$countries['VN'] = array("code"=>"VN","short_name"=>"Vietnam","calling_code"=>"84");
$countries['WF'] = array("code"=>"WF","short_name"=>"Wallis and Futuna","calling_code"=>"681");
$countries['YE'] = array("code"=>"YE","short_name"=>"Yemen","calling_code"=>"967");
$countries['ZM'] = array("code"=>"ZM","short_name"=>"Zambia","calling_code"=>"260");
$countries['ZW'] = array("code"=>"ZW","short_name"=>"Zimbabwe","calling_code"=>"263");
and I simply fetch the values I want using:
$country_code=$_SERVER["HTTP_CF_IPCOUNTRY"];
$country=$countries[''.$country_code.''];
Thus eliminating the need to connect to the DB and use MYSQL.
My question is, is it bad to have this array loaded several times a second? Will it impact performance a lot? Should I simply have a connection to the DB like I previously did?
The server has 16GB of RAM and 8 cores. We're talking about 40-50 thousand visits per day.
Thanks!
First: $country=$countries[''.$country_code.'']; can be replaced with this $country=$countries[$country_code];
This array is definitly the better choice over a Database. Each connection needs some time and arrays can be accessed way faster.
If you want to know exactly how the difference is, you could use this "mini test suite" t determine the runtime difference.
$start1 = microtime(true);
for($i = 0; $i < 10000; $i++)
{
//With database
}
$end1 = microtime(true);
unset(); // The variables which might have been set the section above
$start2 = microtime(true);
for($i = 0; $i < 10000; $i++)
{
//code with array
}
$end2 = microtime(true);
echo $end1-$start1."<br />";
echo $end2-$start2."<br />";
I hope this helps you, if not please let me know.
Pretty sure I mapped the parameters right but still getting this error. I've tried matching up the parameters with the query and they match fine. I've also tried several other things but nothing is solving the issue. Any ideas?
$stmt = $conn->prepare("UPDATE stores SET Name = :Name, Legal_Entity__c = :Legal_Entity__c, Opening_Date__c = :Opening_Date__c, Owner_Type__c = :Owner_Type__c, Yumtracker_Status__c = :Yumtracker_Status__c, Hypercare_Status__c = :Hypercare_Status__c,BOH_Type__c = :BOH_Type__c,Store_Type__c = :Store_Type__c,Address_Line_1__c = :Address_Line_1__c,Address_Line_2__c = :Address_Line_2__c,City__c = :City__c,State__c = :State__c,Zip__c = :Zip__c,Store_Email_Address__c = :Store_Email_Address__c,Time_Zone__c = :Time_Zone__c,Area_Coach__c = :Area_Coach__c,RGM__c = :RGM__c,RTO_Date__c = :RTO_Date__c,Ground_Break_Date__c = :Ground_Break_Date__c,BOH_Install_Date__c = :BOH_Install_Date__c,Primary_BB_Install_Date__c = :Primary_BB_Install_Date__c,TTO_Install_Date__c = :TTO_Install_Date__c,Pre_Cable_Date__c = :Pre_Cable_Date__c,HME_Install_Date__c = :HME_Install_Date__c,Install_Date__c = :Install_Date__c,POS_Install_Date__c = :POS_Install_Date__c,Backup_BB_Install_Date__c = :Backup_BB_Install_Date__c,Telco_Install_Date__c = :Telco_Install_Date__c,Site_Survey_Date__c = :Site_Survey_Date__c,Opening_Support_Date__c = :Opening_Support_Date__c,Sea_Trial__c = :Sea_Trial__c,Mobile__c = :Mobile__c,OCB__c = :OCB__c,BOH__c = :BOH__c,KDS__c = :KDS__c,POS__c = :POS__c,HME__c = :HME__c,Airtight__c = :Airtight__c,LZ__c = :LZ__c,HZ__c = :HZ__c,Technology_Check_Last_Update__c = :Technology_Check_Last_Update__c,Verify_Store_is_in_EDM__c = :Verify_Store_is_in_EDM__c,Verify_AC_RGM_have_INIT_checklist__c = :Verify_AC_RGM_have_INIT_checklist__c,Verify_TACO_eRes_is_INIT__c = :Verify_TACO_eRes_is_INIT__c,Verify_no_issues_with_Tech__c = :Verify_no_issues_with_Tech__c,Verify_Store_Opened__c = :Verify_Store_Opened__c,Verify_store_shows_open_in_Remedy__c = :Verify_store_shows_open_in_Remedy__c,Verify_Gift_Cards_are_active__c = :Verify_Gift_Cards_are_active__c,Days_in_Implementation__c = :Days_in_Implementation__c,Days_in_Hypercare__c = :Days_in_Hypercare__c,Days_to_Stability__c = :Days_to_Stability__c,Verify_Store_can_access_LZ_HZ__c = :Verify_Store_can_access_LZ_HZ__c,Verify_Mobile_MIDs_sent_to_Tillster__c = :Verify_Mobile_MIDs_sent_to_Tillster__c,Verify_store_has_no_issues__c = :Verify_store_has_no_issues__c,Verify_Mobile_and_Gift_Card_setup_start__c = :Verify_Mobile_and_Gift_Card_setup_start__c WHERE Id = '$recordID'");
$stmt->bindParam(':Name', $updatedRecord->Name);
$stmt->bindParam(':Legal_Entity__c', $updatedRecord->Legal_Entity__c);
$stmt->bindParam(':Opening_Date__c', $updatedRecord->Opening_Date__c);
$stmt->bindParam(':Owner_Type__c', $updatedRecord->Owner_Type__c);
$stmt->bindParam(':YumTracker_Status__c', $updatedRecord->YumTracker_Status__c);
$stmt->bindParam(':Hypercare_Status__c', $updatedRecord->Hypercare_Status__c);
$stmt->bindParam(':BOH_Type__c', $updatedRecord->BOH_Type__c);
$stmt->bindParam(':Store_Type__c', $updatedRecord->Store_Type__c);
$stmt->bindParam(':Address_Line_1__c', $updatedRecord->Address_Line_1__c);
$stmt->bindParam(':Address_Line_2__c', $updatedRecord->Address_Line_2__c);
$stmt->bindParam(':City__c', $updatedRecord->City__c);
$stmt->bindParam(':State__c', $updatedRecord->State__c);
$stmt->bindParam(':Zip__c', $updatedRecord->Zip__c);
$stmt->bindParam(':Store_Email_Address__c', $updatedRecord->Store_Email_Address__c);
$stmt->bindParam(':Time_Zone__c', $updatedRecord->Time_Zone__c);
$stmt->bindParam(':Area_Coach__c', $updatedRecord->Area_Coach__c);
$stmt->bindParam(':RGM__c', $updatedRecord->RGM__c);
$stmt->bindParam(':RTO_Date__c', $updatedRecord->RTO_Date__c);
$stmt->bindParam(':Ground_Break_Date__c', $updatedRecord->Ground_Break_Date__c);
$stmt->bindParam(':BOH_Install_Date__c', $updatedRecord->BOH_Install_Date__c);
$stmt->bindParam(':Primary_BB_Install_Date__c', $updatedRecord->Primary_BB_Install_Date__c);
$stmt->bindParam(':TTO_Install_Date__c', $updatedRecord->TTO_Install_Date__c);
$stmt->bindParam(':Pre_Cable_Date__c', $updatedRecord->Pre_Cable_Date__c);
$stmt->bindParam(':HME_Install_Date__c', $updatedRecord->HME_Install_Date__c);
$stmt->bindParam(':Install_Date__c', $updatedRecord->Install_Date__c);
$stmt->bindParam(':POS_Install_Date__c', $updatedRecord->POS_Install_Date__c);
$stmt->bindParam(':Backup_BB_Install_Date__c', $updatedRecord->Backup_BB_Install_Date__c);
$stmt->bindParam(':Telco_Install_Date__c', $updatedRecord->Telco_Install_Date__c);
$stmt->bindParam(':Site_Survey_Date__c', $updatedRecord->Site_Survey_Date__c);
$stmt->bindParam(':Opening_Support_Date__c', $updatedRecord->Opening_Support_Date__c);
$stmt->bindParam(':Sea_Trial__c', $updatedRecord->Sea_Trial__c);
$stmt->bindParam(':Mobile__c', $updatedRecord->Mobile__c);
$stmt->bindParam(':OCB__c', $updatedRecord->OCB__c);
$stmt->bindParam(':BOH__c', $updatedRecord->BOH__c);
$stmt->bindParam(':KDS__c', $updatedRecord->KDS__c);
$stmt->bindParam(':POS__c', $updatedRecord->POS__c);
$stmt->bindParam(':HME__c', $updatedRecord->HME__c);
$stmt->bindParam(':Airtight__c', $updatedRecord->Airtight__c);
$stmt->bindParam(':LZ__c', $updatedRecord->LZ__c);
$stmt->bindParam(':HZ__c', $updatedRecord->HZ__c);
$stmt->bindParam(':Technology_Check_Last_Update__c', $updatedRecord->Technology_Check_Last_Update__c);
$stmt->bindParam(':Verify_Store_is_in_EDM__c', $updatedRecord->Verify_Store_is_in_EDM__c);
$stmt->bindParam(':Verify_AC_RGM_have_INIT_checklist__c', $updatedRecord->Verify_AC_RGM_have_INIT_checklist__c);
$stmt->bindParam(':Verify_TACO_eRes_is_INIT__c', $updatedRecord->Verify_TACO_eRes_is_INIT__c);
$stmt->bindParam(':Verify_no_issues_with_Tech__c', $updatedRecord->Verify_no_issues_with_Tech__c);
$stmt->bindParam(':Verify_Store_Opened__c', $updatedRecord->Verify_Store_Opened__c);
$stmt->bindParam(':Verify_store_shows_open_in_Remedy__c', $updatedRecord->Verify_store_shows_open_in_Remedy__c);
$stmt->bindParam(':Verify_Gift_Cards_are_active__c', $updatedRecord->Verify_Gift_Cards_are_active__c);
$stmt->bindParam(':Days_in_Implementation__c', $updatedRecord->Days_in_Implementation__c);
$stmt->bindParam(':Days_in_Hypercare__c', $updatedRecord->Days_in_Hypercare__c);
$stmt->bindParam(':Days_to_Stability__c', $updatedRecord->Days_to_Stability__c);
$stmt->bindParam(':Verify_Store_can_access_LZ_HZ__c', $updatedRecord->Verify_Store_can_access_LZ_HZ__c);
$stmt->bindParam(':Verify_Mobile_MIDs_sent_to_Tillster__c', $updatedRecord->Verify_Mobile_MIDs_sent_to_Tillster__c);
$stmt->bindParam(':Verify_store_has_no_issues__c', $updatedRecord->Verify_store_has_no_issues__c);
$stmt->bindParam(':Verify_Mobile_and_Gift_Card_setup_start__c', $updatedRecord->Verify_Mobile_and_Gift_Card_setup_start__c);
$stmt->execute();