What I want to do is When I enter all my information (for client ID 199 in the picture) In my account being submit it, it goes into the database. BUT I want it to change to something and so i added an if statement
Here the code im adding to the existing code already at the BOTTOM of the code
if ($vpr_clid == 199) {
$vpr_cl_name = "Shelley Madsen And Associates";
}
if the ($vpr_clid = 199)
i want the clname to be "Shelley Madsen And Associates" then what is show in the table below instead of "Nice and White Smiles" (that an example of the results look like)
but when i chcek the database it not changing it and still show "Nice and White Smiles :(
I dont see any error, so it might be the placement of the code i have to put the IF statement in the huge php file? Dont know how to fix this issue
Thanks (the code below is the base code before i added the If statement)
I also insert the if statement before the function were called but still didnt work example
if ($vpr_clid == 199) {
$vpr_cl_name = "Shelley Madsen And Associates";
}
$result = InsertIntoPayReminder($link, $vars);
$result = GetVpr_Id($link, $vars);
<?php
session_start();
if ($_SESSION['company'] != "ACB") {
// redirect to the logout page
$redirect = 'logout.php';
include './includes/redirect.php';
}
class variables_obj {
var $vpr_plan = '';
var $vpr_id = '';
var $vpr_clid = '';
var $vpr_cl_name = '';
var $vpr_cl_phone = '';
var $vpr_call_start_date = '';
var $vpr_db_account = '';
var $vpr_db_fname = '';
var $vpr_db_mname = '';
var $vpr_db_lname = '';
var $vpr_rp_fname = '';
var $vpr_rp_mname = '';
var $vpr_rp_lname = '';
var $vpr_rp_address = '';
var $vpr_rp_city = '';
var $vpr_rp_state = '';
var $vpr_rp_zipcode = '';
var $vpr_rp_phonenum = '';
var $vpr_rp_phonetype = '';
var $vpr_date_entered = '';
var $newrecdt = '';
var $vpl_day_offset = '';
var $vpl_action = '';
var $vpr_promocode = '';
}
function ScrubPhone($old_phone_num) {
$phone_length = strlen($old_phone_num);
$new_phone_num = "";
for($i = 0; $i < $phone_length; $i = $i + 1) {
if(is_numeric($old_phone_num[$i])) {
$new_phone_num .= $old_phone_num[$i];
}
}
return $new_phone_num;
}
function ScheduleCreated($link, $vars) {
$query = "UPDATE v_payreminder SET vpr_schedule_created = '1' WHERE vpr_id='".$vars->vpr_id."'";
if (!mysql_query($query,$link)) {
die('Error: ' . mysql_error());
}
return true;
}
function CreateScheduleRow($link, $vars){
// echo "vpl_day_offset: ".$vars->vpl_day_offset."<br>";
// echo "vpl_action: ".$vars->vpl_action."<br>";
$plus_days = " +".$vars->vpl_day_offset." days";
// echo "plus days: ".$plus_days."<br>";
$date_offset = strtotime(date("Y-m-d", strtotime($vars->vpr_date_entered)).$plus_days);
$date_offset = date("Y-m-d", $date_offset);
// echo "date_offset: ".$date_offset."<br>";
// $date_offset = strtotime(date("Y-m-d",strtotime($vars->vpr_date_entered))." +".$vars->vpl_day_offset." days");
// $date_offset = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
// echo "date_offset: ".$date_offset."<br>";
$query = "INSERT INTO v_pr_schedule (
vpr_id,
vsc_plan,
vsc_date_entered,
vsc_action,
vsc_action_date,
vsc_status
) VALUES (
'$vars->vpr_id',
'$vars->vpr_plan',
'$vars->vpr_date_entered',
'$vars->vpl_action',
'$date_offset',
'VACT')";
//echo "query: ".$query."<br>";
if (!mysql_query($query,$link)) {
die('Error: ' . mysql_error());
}
return true;
}
function CreateSchedule($link, &$vars) {
// CREATE SCHEDULE
$query = " SELECT vpl_day_offset, vpl_action, vpl_condition
FROM v_plan
WHERE vpl_plan = '".$vars->vpr_plan."'";
// echo "query: ".$query."<br>";
$qresult = mysql_query($query);
if (!$qresult) {
print(mysql_error());
}
if ($qresult && mysql_num_rows($qresult) > 0 ) {
while ($row = mysql_fetch_array($qresult, MYSQL_ASSOC)) {
$vars->vpl_day_offset = $row['vpl_day_offset'];
$vars->vpl_action = $row['vpl_action'];
if ($row['vpl_condition'] == 'OO') {
CreateScheduleRow($link, $vars);
}
}
}
return true;
}
function InsertIntoPayReminder($link, &$vars) {
$vars->vpr_cl_name = strtr($vars->vpr_cl_name, "'", " ");
//echo "Client Name: ".$vars->vpr_cl_name."<br><br>";
//exit();
$sql="INSERT INTO v_payreminder (
vpr_clid,
vpr_cl_name,
vpr_cl_phone,
vpr_call_start_date,
vpr_db_account,
vpr_db_fname,
vpr_db_mname,
vpr_db_lname,
vpr_rp_fname,
vpr_rp_mname,
vpr_rp_lname,
vpr_rp_phonenum,
vpr_rp_phonetype,
vpr_rp_address,
vpr_rp_city,
vpr_rp_state,
vpr_rp_zipcode,
vpr_promo,
vpr_date_entered) VALUES (
'$vars->vpr_clid',
'$vars->vpr_cl_name',
'$vars->vpr_cl_phone',
'$vars->vpr_call_start_date',
'$vars->vpr_db_account',
'$vars->vpr_db_fname',
'$vars->vpr_db_mname',
'$vars->vpr_db_lname',
'$vars->vpr_rp_fname',
'$vars->vpr_rp_mname',
'$vars->vpr_rp_lname',
'$vars->vpr_rp_phonenum',
'$vars->vpr_rp_phonetype',
'$vars->vpr_rp_address',
'$vars->vpr_rp_city',
'$vars->vpr_rp_state',
'$vars->vpr_rp_zipcode',
'$vars->vpr_promocode',
'$vars->vpr_date_entered')";
if (!mysql_query($sql,$link)) {
die('Error2: ' . mysql_error());
}
return true;
}
function GetVpr_Id($link, &$vars) {
// Find out what vpr_id is
$query = "SELECT vpr_id FROM v_payreminder ";
$query .= "WHERE vpr_clid = '".$vars->vpr_clid."' AND vpr_date_entered = '".$vars->vpr_date_entered."'";
$qresult = mysql_query($query);
if (!$qresult) {
print(mysql_error());
}
if ($qresult && mysql_num_rows($qresult) > 0 ) {
$row = mysql_fetch_array($qresult, MYSQL_ASSOC);
$vars->vpr_id = $row['vpr_id'];
}
}
function InsertInActivity($link, $vars) {
// ENTER INTO ACTIVITY
$vaction_desc = 'PATIENT ENTERED';
$sql = "INSERT INTO v_pr_activity (
vpr_id,
va_plan,
va_action_dttm,
va_action_code,
va_action_desc,
va_disposition_code,
va_disposition_desc,
va_status_code,
va_status_desc
) VALUES (
'$vars->vpr_id',
'$vars->vpr_plan',
'$vars->vpr_date_entered',
'VINIT',
'$vaction_desc',
'SUCCESS',
'SUCCESS',
'VACT',
'ACTIVE'
)";
if (!mysql_query($sql,$link)) {
die('Error: ' . mysql_error());
}
}
include './includes/dblogin.php';
$vars = new variables_obj();
$vars->vpr_plan = 'VP01';
$vars->vpr_clid = $_SESSION['userid'];
//-------------------------------------------------------
// No commas can be in client name or they will
// mess up the Global Connect CSV file.
//-------------------------------------------------------
$vpr_cl_name = $_SESSION['username'];
$vpr_cl_name = str_replace(",", " ", $vpr_cl_name);
$vars->vpr_cl_name = $vpr_cl_name;
//-------------------------------------------------------
//-------------------------------------------------------
$vars->vpr_cl_phone = ScrubPhone($_SESSION['uphone']);
$vars->vpr_call_start_date = '0000-00-00';
$vars->vpr_db_account = $_POST['ndaccnum'];
$vars->vpr_db_fname = $_POST['ndfreqname'];
$vars->vpr_db_mname = $_POST['ndmname'];
$vars->vpr_db_lname = $_POST['ndlreqname'];
$vars->vpr_rp_fname = $_POST['ndrfreqname'];
$vars->vpr_rp_mname = $_POST['ndrmname'];
$vars->vpr_rp_lname = $_POST['ndrlreqname'];
$vars->vpr_rp_address = '';
$vars->vpr_rp_city = '';
$vars->vpr_rp_state = $_POST['ndrstatereqname'];
$vars->vpr_rp_zipcode = $_POST['ndrreqzipcode'];
$phonenumber = $_POST['1ndrreqphone'].$_POST['2ndrreqphone'].$_POST['3ndrreqphone'];
$vars->vpr_rp_phonenum = $phonenumber;
$vars->vpr_rp_phonetype = $_POST['treqphone'];
$vars->vpr_date_entered = date('Y-m-d H:i:s');
$vars->newrecdt = date('Ymd');
$vars->vpr_promocode = $_POST['promocode'];
// echo "vpr_plan: ".$vars->vpr_plan."<br>";
// echo "vpr_date_entered: ".$vars->vpr_date_entered."<br>";
// echo "newrecdt: ".$vars->newrecdt."<br>";
// echo "vpr_clid: ".$vars->vpr_clid."<br>";
// echo "vpr_id: ".$vars->vpr_id."<br>";
$result = InsertIntoPayReminder($link, $vars);
$result = GetVpr_Id($link, $vars);
$result = InsertInActivity($link, $vars);
$result = CreateSchedule($link, $vars);
$result = ScheduleCreated($link, $vars);
// echo "vpr_id: ".$vars->vpr_id."<br>";
mysql_close($link);
// redirect
$redirect = 'vpayremind.php';
include './includes/redirect.php';
?>
okay referencing the following lines..
if ( $vpr_clid == 199 ) {
$vpr_cl_name = "Shelley Madsen And Associates";
}
$result = InsertIntoPayReminder($link, $vars);
...and then:
function InsertIntoPayReminder($link, &$vars) {
$vars->vpr_cl_name = strtr($vars->vpr_cl_name, "'", " ");
so on and so forth... }
it doesnt seem as if you are actually setting the value of the class object. You seem to be setting some arbitrary php variable to the name you want, and then passing a totally different ' $vars ' object into the function. I don't see any reason to believe that the ' $vars ' you are passing into the function call contains the name value you want it to contain. You should be assigning the value of ' $vars ' before passing it in.
For instance:
if ( $vpr_clid == 199 ) {
$vars[ 'vpr_cl_name' ] = "Shelley Madsen And Associates";
}
then you can get rid of this line all together:
$vars->vpr_cl_name = strtr($vars->vpr_cl_name, "'", " ");
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();