benlucraft Posted January 23, 2016 Share Posted January 23, 2016 Hi fellow coders, got a little issue with a Gym mod for V2 everything works ok except when i attempt to train my strength i get this error when i turn debug on Line executed: /home/colleg30/public_html/gym.php:22 This stat cannot be trained. Below is lines 20-30 if($_POST['stat'] && $_POST['amnt']) { $stat=$statnames[$_POST['stat']]; if(!$stat); { die("This stat cannot be trained."); } if($_POST['amnt'] > $ir['energy']) { print("You do not have enough energy to train that much.<hr />"); What is my issue? everything else is ok? Quote Link to comment Share on other sites More sharing options...
Mcfarlin Posted January 23, 2016 Share Posted January 23, 2016 if (isset($_POST['stat']) && $_POST['amnt']) { if (!isset($statnames[$_POST['stat']])) { die("This stat cannot be trained."); } $stat = $statnames[$_POST['stat']]; if ($_POST['amnt'] > $ir['energy']) { print("You do not have enough energy to train that much.<hr />"); } Should work for you. Just make sure when you add this to your gym file you take out the { } not needed, the code you posted does not have the closing } in it. 1 Quote Link to comment Share on other sites More sharing options...
benlucraft Posted January 23, 2016 Author Share Posted January 23, 2016 if (isset($_POST['stat']) && $_POST['amnt']) { if (!isset($statnames[$_POST['stat']])) { die("This stat cannot be trained."); } $stat = $statnames[$_POST['stat']]; if ($_POST['amnt'] > $ir['energy']) { print("You do not have enough energy to train that much.<hr />"); } Should work for you. Just make sure when you add this to your gym file you take out the { } not needed, the code you posted does not have the closing } in it. Ill give it a shot thanks Mcfarlin! +1 Quote Link to comment Share on other sites More sharing options...
Mcfarlin Posted January 23, 2016 Share Posted January 23, 2016 Seeing as that did not work. Removing the extra comma from your stats array did not help. Idk what it is. sorry i want more help. Quote Link to comment Share on other sites More sharing options...
AdamHull Posted January 23, 2016 Share Posted January 23, 2016 You might need to add your stat array here so we can look at that aswell Quote Link to comment Share on other sites More sharing options...
benlucraft Posted January 23, 2016 Author Share Posted January 23, 2016 You might need to add your stat array here so we can look at that aswell $statnames=array( 'Strength' => 'strength', 'Agility' => 'agility', 'Labour ' => 'labour', 'Guard' => 'guard'); I got the strength training to work but now it will not let me train my Labour it just says cannot train stat... Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted January 23, 2016 Share Posted January 23, 2016 Does your post value return Strength or strength? $statnames['Strength']; // would return strength $statnames['strength']; // would return E_NOTICE for undefined index strength Quote Link to comment Share on other sites More sharing options...
benlucraft Posted January 23, 2016 Author Share Posted January 23, 2016 Does your post value return Strength or strength? $statnames['Strength']; // would return strength $statnames['strength']; // would return E_NOTICE for undefined index strength The strength now works but labour doesn't Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.