MasterACE14 Posted June 29, 2008 Share Posted June 29, 2008 The problem is, I have multiple if's and am lost in the order now :-\ , its now throwing me a error after adding a few else's code: <?php if($player['currenthealth'] >= 1 && $player['tcf_check'] == 0 && $other_player['tcf_check'] == 0 && $other_player['allianceid'] != $player['allianceid'] && $other_player['alliancename'] != $player['alliancename']) { if($other_player['alliancename'] == "none" && $player['currenthealth'] >= 1 && $player['tcf_check'] == 0 && $other_player['tcf_check'] == 0) { if($other_player['location'] == "At War" && $player['location'] == "At War") { ?> <tr> <form name="player_interaction_attack" method="post" action="index.php?page=player_interaction_result"> <td><center> Ammo: </center></td> <td><center> <input type="text" size="4" maxlength="10" name="ammo"> / 20 </center></td> <input type="hidden" name="otherplayersid" value="<?=$other_player['id']?>"> <td><center> <input type="submit" value="Attack" onClick="return checksubmit(this)"> </center></td> </form> </tr> <tr><td> </td></tr> <?php } else { die("<center>You can not attack someone when you are At Home or they are At Home</center>"); } } else { die("<center>You can not attack someone if your health is zero and if you are on Temporary Cease Fire</center>"); } } ?> <?php elseif($player['currenthealth'] == 0) { // this is line 225 ?> error: Parse error: syntax error, unexpected T_ELSEIF in /home/ace/public_html/conflictingforces/lib/player_interaction.php on line 225 any help is greatly appreciated Regards ACE Quote Link to comment Share on other sites More sharing options...
trq Posted June 29, 2008 Share Posted June 29, 2008 Can you indent your code logically so we can read it? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted June 29, 2008 Author Share Posted June 29, 2008 <?php if ($player['currenthealth'] >= 1 && $player['tcf_check'] == 0 && $other_player['tcf_check'] == 0 && $other_player['allianceid'] != $player['allianceid'] && $other_player['alliancename'] != $player['alliancename']) { if ($other_player['alliancename'] == "none" && $player['currenthealth'] >= 1 && $player['tcf_check'] == 0 && $other_player['tcf_check'] == 0) { if ($other_player['location'] == "At War" && $player['location'] == "At War") { ?> <tr> <form name="player_interaction_attack" method="post" action="index.php?page=player_interaction_result"> <td><center> Ammo: </center></td> <td><center> <input type="text" size="4" maxlength="10" name="ammo"> / 20 </center></td> <input type="hidden" name="otherplayersid" value="<?=$other_player['id']?>"> <td><center> <input type="submit" value="Attack" onClick="return checksubmit(this)"> </center></td> </form> </tr> <tr><td> </td></tr> <?php } else { die("<center>You can not attack someone when you are At Home or they are At Home</center>"); } } else { die("<center>You can not attack someone if your health is zero and if you are on Temporary Cease Fire</center>"); } } ?> <?php elseif ($player['currenthealth'] == 0) { // this is line 225 ?> Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 29, 2008 Share Posted June 29, 2008 are all the nested if's supposed to be separate conditionals? or is it "if this... then if this... then if this... then do whatever" or is it "if this, then this, else if this, then this, else if..." ? And change the last to "else if". you need a space between the 2. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted June 29, 2008 Author Share Posted June 29, 2008 I've just fixed the error, but its now echoing something it shouldn't. <?php if ($player['currenthealth'] >= 1 && $player['tcf_check'] == 0 && $other_player['tcf_check'] == 0 && $other_player['allianceid'] != $player['allianceid'] && $other_player['alliancename'] != $player['alliancename']) { if ($other_player['alliancename'] == "none" && $player['currenthealth'] >= 1 && $player['tcf_check'] == 0 && $other_player['tcf_check'] == 0) { if ($other_player['location'] == "At War" && $player['location'] == "At War") { ?> <tr> <form name="player_interaction_attack" method="post" action="index.php?page=player_interaction_result"> <td><center> Ammo: </center></td> <td><center> <input type="text" size="4" maxlength="10" name="ammo"> / 20 </center></td> <input type="hidden" name="otherplayersid" value="<?=$other_player['id']?>"> <td><center> <input type="submit" value="Attack" onClick="return checksubmit(this)"> </center></td> </form> </tr> <tr><td> </td></tr> <?php } else { echo("<center>You can not attack someone when you are At Home or they are At Home</center>"); } } else { echo("<center>You can not attack someone if your health is zero and if you are on Temporary Cease Fire</center>"); } } elseif ($player['currenthealth'] == 0) { // this is line 225 ?> it's echoing... You can not attack someone if your health is zero and if you are on Temporary Cease Fire EDIT: its displaying that because users are default placed in the alliance 'none'. but to the game this is scene as an alliance. any ideas on how to fix up the IF to make it so it displays the form regardless of what alliance the logged in user ($player) is in. As long as it isn't the same as the one the logged in user is in(with the exception of the alliance 'none') Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted June 29, 2008 Author Share Posted June 29, 2008 Problem solved. I created a alliance name, and alliance id variable, then did a if statement to check if the other players alliance name was equal to 'none' and if there alliance id is equal to zero, and if it is I appended a random number to the end of the alliance name and the id and use that in my if statement to check whether to display the form or not. Thanks for your help people. Regards ACE 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.