Blah!! I can't figure out what's wrong with this php code and I can't figure out what! My debugger sees no errors in it, yet the script won't run! I know it's not the includes because they run correctly everywhere else except for buytown.post.php..
buytown.php
[PHP]
<?php
session_start();
//$_SESSION['user'] is the logged-in user's id number used to get data.
echo "<head>
<title>Empirez! The Online Empire Building Game | Build a Town</title>";
include ("includes/pageheader.php"); //included in all pages viewable
include ("includes/navbar.php"); //included in all pages viewable
include ("server/db_conn.php"); //Connect to the database
if (!isset($_SESSION['user'])) {
echo "<script language=\"javascript\" type=\"text/javascript\">alert(\"You must log in to do that!\")
parent.location=\"login.php\"</script>";
} else {
$id=$_SESSION['user']; //The $_SESSION['user'] would be an id number if it is set.
$query=mysql_query("SELECT * FROM `users` WHERE `id`='$id'");
$genarray=mysql_fetch_array($query); //General info array
settype($towncost, "float"); //Float the town cost
settype($genarray['money'], "float");
$towncost=($genarray['towns']*2800)/3; //Calculate the cost per town
$cost=round($towncost, 2); //Round the town costs
include ("server/buytown.post.php");
echo "
<td colspan=\"2\">
.: Buy a Town :.
</td>
</tr>
<tr>
<td>
Current Funds:
</td>
<td>
<font color=\"#009900\"<b>$".round($genarray['money'], 2)."</b></font>
</td>
</tr>
<tr>
<td>
Current Towns:
</td>
<td>
".$genarray['towns']."
</td>
</tr>
<tr>
<td>
Cost Per Town:
</td>
<td>
".$cost."
<input type=\"hidden\" value=".$cost." name=\"cost\">
</td>
</tr>
<tr>
<td>
Purchase Amount:
</td>
<td>
<input type=\"text\" name=\"numer\" length=\"20\">
</td>
</tr>
<tr>
<td colspan=\"2\">
<input type=\"submit\" value=\"Purchase\">
<input type=\"submit\" value=\"Confirm Purchase\">
</td>
</tr>
</table>";
}
include ("includes/pagefooter.php"); //At the end of all pages viewable
mysql_close();
?>[/PHP]
buytown.post.php
[PHP]<?php
$number=$_POST['number'];
if ($number!=NULL) {
if ($genarray['money']>=($cost*$number)) {
settype($purchase, "float");
$purchase=$cost*$number;
round($purchase, 2);
mysql_query("UPDATE `users` WHERE `id`='$id' SET `towns`=`towns`+'$number'");
echo "
<script language=\"javascript\" type=\"text/javascript\">alert(\"Town built successfully.\")
parent.location=\"viewempire.php\"</script>";
} else {
echo "
<script language=\"javascript\" type=\"text/javascript\">alert(\"Not enough funds!!\")</script>";
}
}
?>[/PHP]