I just started learning php on monday for something fun to do.
I'm working on a little "tool" that will basically take information from a user and format it into a block of text they can copy and paste.
Pretty simple.
I learned enough css to apply it to my program but now it seems to be fudged (which I'm sure is something I did)
It simply tells me "Parse error: syntax error, unexpected $end in /homepages/43/d156462996/htdocs/php/defense_dev.php on line 257"
But I know I probably forgot to close a bracket or something retarded, I've just been staring at it for about 2 hours and can't see it.
Line 257 is "</html>"
So my questions are
1. Is there a better way of debugging than by searching through guessing for errors?
2. Can you take a look and see if you see anything obvious?
I did everything by hand in a text editor (ultraedit) so if the formatting is odd, I am quite sorry.
Thanks!
I'm working on a little "tool" that will basically take information from a user and format it into a block of text they can copy and paste.
Pretty simple.
I learned enough css to apply it to my program but now it seems to be fudged (which I'm sure is something I did)
It simply tells me "Parse error: syntax error, unexpected $end in /homepages/43/d156462996/htdocs/php/defense_dev.php on line 257"
But I know I probably forgot to close a bracket or something retarded, I've just been staring at it for about 2 hours and can't see it.
Line 257 is "</html>"
So my questions are
1. Is there a better way of debugging than by searching through guessing for errors?
2. Can you take a look and see if you see anything obvious?
Code:
<html>
<head>
<title>Pack Defense Request Builder v0.1</title>
<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>
<link rel=stylesheet href="style.css" type="text/css">
</head>
<?php
/*
Will be used to generate properly formatted defense requests and some form of catapult detection
*/
?>
<body>
<?php
if(isset($_POST['user']))
{
//User Information
$user = $_POST['user'];
$usercity = $_POST['usercity'];
$user_xcord = $_POST['user_xcord'];
$user_ycord = $_POST['user_ycord'];
$grancap = $_POST['grancap'];
$wheat = $_POST['wheat'];
$wall = $_POST['wall'];
$curD = $_POST['curD'];
$sitter1 = $_POST['sitter1'];
$sitter2 = $_POST['sitter2'];
$platoon = $_POST['platoon'];
$division = $_POST['Division'];
//Attack Information
$attacktype = $_POST['attacktype'];
$attname = $_POST['attacker'];
$alliance = $_POST['alliance'];
$attcity = $_POST['attcity'];
$att_xcord = $_POST['att_xcord'];
$att_ycord = $_POST['att_ycord'];
$breport= $_POST['breport'];
//Catapult detection
$atttime1 = $_POST['atttime1'];
$landtime = $_POST['landtime'];
}
?>
<h3 class="header" align="center">Pack Defense Request Builder</h3>
<table border="1" align="center">
<tr>
<td>
<table>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<td>
<tr>
<td><h5 class="header">User Information<h5></td>
</tr>
<tr>
<td class="sText">User name:</td>
<td>
<input type="text" class="form" name="user" size="30" value="<?php echo $user; ?>">
</td>
</tr>
<tr>
<td class="sText">Your city name & coords</td>
<td class="sText">
<input type="text" class="form" name="usercity" size="30" value="<?php echo $usercity; ?>">
X:<input type="text" class="form" name="user_xcord" size="4" value=<?php echo $user_xcord; ?>>
Y:<input type="text" class="form" name="user_ycord" size="4" value=<?php echo $user_ycord; ?>>
</td>
</tr>
<tr>
<td class="sText">Granary Capacity</td>
<td class="sText">
<input type="text" class="form" name="grancap" size="12" value="<?php echo $grancap; ?>">
Current amount of wheat: <input type="text" class="form" name="wheat" size="10" value="<?php echo $wheat; ?>">
</td>
</tr>
<tr>
<td class="sText">Wall Level</td>
<td><input type="text" class="form" name="wall" size="12" value="<?php echo $wall; ?>"></td>
</tr>
<tr>
<td class="sText">Current Defenses</td>
<td><textarea class="textarea" name="curD" rows="3" cols="50"><?php echo $curD; ?></textarea></td>
</tr>
<tr>
<td class="sText">Sitters</td>
<td>
<input type="text" class="form" name="sitter1" value=<?php echo $sitter1; ?>>
<input type="text" class="form" name="sitter2" value=<?php echo $sitter2; ?>>
</td>
</tr>
<tr>
<td class="sText">Division</td>
<td>
<select class="form" name="Division">
<option value=<? echo $division; ?>><? echo $division; ?></option>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
</select>
</td>
</tr>
<tr>
<td class="sText">Platoon</td>
<td>
<select class="form" name="platoon">
<option value=<? echo $platoon; ?>><? echo $platoon; ?></option>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
</select>
</td>
</tr>
</td>
</table>
<td>
<table>
<tr>
<td><h5 class="header">Attack Information<h5></td>
</tr>
<tr>
<td class="sText">Attack Type</td>
<td>
<select class="form" name="attacktype">
<option value=<? echo $attacktype; ?>><? echo $attacktype; ?></option>
<option value=Attacked>Attacked</option>
<option value=Attack>Attack</option>
</select>
</td>
</tr>
<tr>
<td class="sText">Time attacks were first noticed by you</td>
<td>
<input class="form" id="atttime1" type="text" name="atttime1" value="<?php echo $atttime1; ?>">
<a href="javascript:NewCal('atttime1','mmddyyyy',true,24)"><img src="images/cal.gif" width="16" height="16" border="0" alt=Pick a date"></a>
</td>
</tr>
<tr>
<td class="sText">Time attack will land (EST)</td>
<td>
<input type="text" class="form" id="landtime" name="landtime" value="<?php echo $landtime; ?>">
<a href="javascript:NewCal('landtime','mmddyyyy',true,24)"><img src="images/cal.gif" width="16" height="16" border="0" alt=Pick a date"></a>
</td>
</tr>
<tr>
<td class="sText">Attacker Name</td>
<td>
<input type="text" class="form" name="attacker" size="30" value="<?php echo $attname; ?>">
</td>
</tr>
<tr>
<td class="sText">Alliance</td>
<td>
<input type="text" class="form" name="alliance" size="30" value="<?php echo $alliance; ?>">
</td>
</tr>
<tr>
<td class="sText">Attacker city name & coords</td>
<td class="sText">
<input type="text" class="form" name="attcity" size="30" value="<?php echo $attcity; ?>">
X:<input type="text" class="form" name="att_xcord" size="4" value=<?php echo $att_xcord; ?>>
Y:<input type="text" class="form" name="att_ycord" size="4" value=<?php echo $att_ycord; ?>>
</td>
</tr>
<tr>
<td class="sText">Battle Reports</td>
<td>
<textarea class="textarea" name="breport" rows="5" cols="50"><?php echo $breport; ?></textarea>
</td>
</tr>
</td>
</table>
</tr>
</table>
<tr>
<table align="center">
<td class="form" width=300 align="center"><?php $currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);?>
<input type="button" value="Restart" onClick="parent.location='<?php echo $parts[count($parts) - 1];?>'">
<input type="submit" value="Build Defense Request"></td>
</table>
</tr>
</tr>
</form>
<?php
if(isset($_POST['user']))
{
?>
<table border="3" align="center" cellpadding="3" cellspacing="0">
<tr>
<h5 align=center class="header">Subject Line: <?php echo $user . " - " . $usercity ." (". $user_xcord ."|". $user_ycord .") ". $attacktype ." by ". $attname ." - ". $attcity ." (". $att_xcord ."|". $att_ycord .") of ". $alliance; ?></h5>
</tr>
<tr>
<td class="output">
<?php echo $user ."'s village ". $usercity ." (". $user_xcord ."|". $user_ycord .") ";?><br>
<?php echo $attacktype ." by ". $attname ." - ". $attcity ." (". $att_xcord ."|". $att_ycord .") of ". $alliance; ?><br>
<?php echo "Attack(s) land at " . $landtime . " (or battle report posted below.)"; ?><br>
<?php echo $breport; ?><br>
<?php echo "Granary Information (". $wheat ."/". $grancap .")"; ?><br>
<?php echo "Wall level: " . $wall; ?><br>
<?php if(empty($sitter1) and empty($sitter2)){}
else{echo "Sitters: " . $sitter1 .", " . $sitter2;}?>
<?php echo "Division " . $division; ?><br>
<?php echo "Platoon " . $platoon; ?><br>
<?php echo "Current Defenses: " . $curD; ?><br>
<?php $distance = sqrt((($user_xcord - $att_xcord)*($user_xcord - $att_xcord))+(($user_ycord - $att_ycord)*($user_ycord - $att_ycord)));?>
<?php echo "Distance From " . " (". $att_xcord ."|". $att_ycord .") to (". $user_xcord ."|". $user_ycord .") =". $distance;?><br>
<?php $tsquare =0;
$unitspeed = 3; ?>
<?php if($distance < 30) {$triptime = $distance / $unitspeed; }
else{
$triptime = ((30 / $unitspeed)+(($distance-30) / ($unitspeed*(1+($tsquare/10)))));}
?>
<?php echo "Travel time by catapult from " . "(" . $att_xcord ."|". $att_ycord . ") to (" . $user_xcord . "|" . $user_ycord . ") is " . $triptime;?><br>
<?php $unix_launchtime = strtotime($landtime) - (60 * $triptime * 60);?>
<?php echo "Launch time if catapults are present: " . date("m/d @ H:i:s", $unix_launchtime);?>
</td>
</tr>
</table>
</body>
</html>
I did everything by hand in a text editor (ultraedit) so if the formatting is odd, I am quite sorry.
Thanks!