I have an application that will connect with an unofficial Overwatch API and get that player's info and store it in my database. I run through how I get the infomration just to make sure it's not a problem somewhere else.
I start with having each of the heroes inside an array like so:
$heroArray = array(
"zenyatta" => "0",
"mei" => "0",
"tracer" => "0",
"soldier76" => "0",
"anaamari" => "0",
"roadhog" => "0",
"reinhardt" => "0",
"torbjorn" => "0",
"mccree" => "0",
"junkrat" => "0",
"dva" => "0",
"winston" => "0",
"hanzo" => "0",
"widowmaker" => "0",
"reaper" => "0", //this hero is causing problems later
"pharah" => "0", //this hero is causing problems later
"symmetra" => "0", //this hero is causing problems later
"genji" => "0",
"lucio" => "0",
"bastion" => "0",
"mercy" => "0",
"zarya" => "0",
"sombra" => "0"
);
The values are set to zero as the values to be filled will be the amount of hours the player has played with this hero. Then the heros are looped through to get the infomration from the JSON file the API has returned.
foreach($heroArray as $key => $value){
$value = floatval($json[$region]['heroes']['stats']['quickplay'][$key]['general_stats']['time_played']);
}
The array and other values are then passed to the alterPlayer function. The SQL code is as follows:
$sqlQuery= "UPDATE player SET timeplayed = :timeplayed, prestige = :prestige , level = :level, avatar = :avatar, wins = :wins, Zenyatta = :zenyatta, Mei = :mei, Tracer = :tracer, Soldier76 = :soldier76, Anaamari = :anaamari, Roadhog = :roadhog, Reinhardt = :reinhardt, Torbjorn = :torbjorn, Mccree = :mccree, Junkrat = :junkrat, Dva = :dva, Winston = :winston, Hanzo = :hanzo, Widowmaker = :widowmaker, Reaper = :reaper, Pharah = :pharah, Symmetra = :symmetra, Genji = :genji, Lucio = :lucio, Bastion = :bastion, Mercy = :mercy, Zarya = :zarya, Sombra = :sombra, TopHero :heroTopName, SecondHero = :heroSecondName, ThirdHero = :heroThirdName, TopHeroElim = :heroTopElim, TopHeroDeath = :heroTopDeath, SecondHeroElim = :heroSecondElim, SecondHeroDeath = :heroSecondDeath, ThirdHeroElim = :heroThirdElim, ThirdHeroDeath = :heroThirdDeath WHERE Battletag = :battletag";
And then the values are assigned in the params array(I have removed some of the values to save room here):
$params = array(
"junkrat" => $heroArray['junkrat'],
"dva" => $heroArray['dva'],
"winston" => $heroArray['winston'],
"hanzo" => $heroArray['hanzo'],
"widowmaker" => $heroArray['widowmaker'],
"reaper" => $heroArray['reaper'], //problem
"pharah" => $heroArray['pharah'], //problem
"symmetra" => $heroArray['symmetra'], //problem
"genji" => $heroArray['genji'],
"lucio" => $heroArray['lucio'],
"bastion" => $heroArray['bastion'],
"mercy" => $heroArray['mercy']
);
When I run this in command line I get the following error:
C:\Windows\system32>C:/xampp\php\php.exe C:\xampp\htdocs\overwatch\alterPlayer.php
NULL
Notice: Undefined index: reaper in C:\xampp\htdocs\overwatch\PlayerTableGateway.php on line 123
Notice: Undefined index: pharah in C:\xampp\htdocs\overwatch\PlayerTableGateway.php on line 124
Notice: Undefined index: symmetra in C:\xampp\htdocs\overwatch\PlayerTableGateway.php on line 125
Could not update player
So the heroes that are causing problems are reaper, pharah and symmetra. If anyone can spot the error it would be very much appreciated!!