versus1994 Posted October 22, 2017 Share Posted October 22, 2017 Hey guys!So I have some trouble with this fatal error: Cannot access empty property And the line of error is: $returntime = $units->$y['endtime']-time(); More of the code if it's not enough: $DefenderUnit = array(); $DefenderUnit = $database->getUnit($data['to']); $evasion = $database->getVillageField($data['to'],"evasion"); $maxevasion = $database->getUserField($DefenderID,"maxevasion",0); $gold = $database->getUserField($DefenderID,"gold",0); $playerunit = ($targettribe-1)*10; $cannotsend = 0; $movements = $database->getMovement("34",$data['to'],1); for ($y = 0; $y < count($movements); $y++) { $returntime = $units->$y['endtime']-time(); if ($units->$y['sort_type'] == 4 && $units->$y['from'] != 0 && $returntime <= 10) { $cannotsend = 1; } } if ($evasion == 1 && $maxevasion > 0 && $gold > 1 && $cannotsend == 0 && $dataarray[$data_num]['attack_type'] > 2) { $totaltroops = 0; for ($i = 1; $i <= 10; $i++) { $playerunit += $i; $data['u'.$i] = $DefenderUnit['u'.$playerunit]; $database->modifyUnit($data['to'],array($playerunit),array($DefenderUnit['u'.$playerunit]),array(0)); $playerunit -= $i; $totaltroops += $data['u'.$i]; } $data['u11'] = $DefenderUnit['hero']; $totaltroops += $data['u11']; if ($totaltroops > 0) { $database->modifyUnit($data['to'],array("hero"),array($DefenderUnit['hero']),array(0)); $attackid = $database->addAttack($data['to'],$data['u1'],$data['u2'],$data['u3'],$data['u4'],$data['u5'],$data['u6'],$data['u7'],$data['u8'],$data['u9'],$data['u10'],$data['u11'],4,0,0,0,0,0,0,0,0,0,0,0); $database->addMovement(4,0,$data['to'],$attackid,microtime(true),microtime(true)+(180/EVASION_SPEED)); $newgold = $gold-2; $newmaxevasion = $maxevasion-1; $database->updateUserField($DefenderID, "gold", $newgold, 1); $database->updateUserField($DefenderID, "maxevasion", $newmaxevasion, 1); } } Any ideas? Link to comment Share on other sites More sharing options...
requinix Posted October 22, 2017 Share Posted October 22, 2017 $units->$y['endtime']That has one of two meanings, depending on your version of PHP, but neither of which are what you want: 1. Take $units, find a property named according to the value of $y, then treat it as an array and get its 'endtime' value. 2. Take $y, treat it as an array and gets its 'endtime' value, then use that value as the name of a property in the $units object. In other words, writing "$y" makes it a variable and not a name of a property. Drop the $. $units->y['endtime'] Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.