Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I'm not sure where I made a mistake in the following script can anyone please assist
batttle.php
HTML
<html>
<body>
<?php

$a = $_GET["attack"];
$d = $_GET["defence"];
$attacker = (($d / $a)^1.5]));
$defender = (($a / $d)^1.5]);
?>
<br>
Simple Battle Calculator<br><br>

Attack HP: <?php echo $_GET["attack"]; ?><br>
Attack HP:<?php echo $_GET["defence"]; ?><br><br><br>

"><?php if ( $defender >= 100 ) {echo "Attacker wins.";} else { echo "Defender wins.";} ?><br>

<p>Attacker ship loss: <span style="color:red"><?php if ($attacker >= 100 ) {echo "100";} else {
echo $attacker;} ?></span>%<br>

<br><br>
Defender ship loss: <span style="color:red"><?php if ( $defender >= 100 ) {echo "100";} else { echo $defender;} ?></span>% <br>

include "menu2.php";

?>
</body>
</html>


index.php (form)

PHP
<pre lang="xml"><!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body> <form method="get" action="battle.php">
Attack HP:<input type="text" name="attack" value="<?php echo $attack;?>"><br><br>
Defence HP:<input type="text" name="defence" value="<?php echo $defence;?>"><br><br>

<input type="submit" name="submit" value="Submit">
</form><br><br><p></a>
</body>
</html>
Posted
Updated 25-Aug-14 6:14am
v2
Comments
Sergey Alexandrovich Kryukov 25-Aug-14 12:09pm    
How can anyone find out what's wrong without seeing all code, including the form?
—SA
cobusbo 25-Aug-14 12:12pm    
I think my main problem is with the calculation line 5 - 8, I will add the form now sorry

1 solution

Small error, there is an extra closing parenthesis in line 7. This may cause Parsing error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900