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.ph p..
buytown.php
[PHP]
<?php
session_start() ;
//$_SESSION['user'] is the logged-in user's id number used to get data.
echo "<head>
<title>Empire z! 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($_SESSI ON['user'])) {
echo "<script language=\"java script\" type=\"text/javascript\">al ert(\"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_qu ery("SELECT * FROM `users` WHERE `id`='$id'");
$genarray=mysql _fetch_array($q uery); //General info array
settype($townco st, "float"); //Float the town cost
settype($genarr ay['money'], "float");
$towncost=($gen array['towns']*2800)/3; //Calculate the cost per town
$cost=round($to wncost, 2); //Round the town costs
include ("server/buytown.post.ph p");
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=\"Purchas e\">
<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.ph p
[PHP]<?php
$number=$_POST['number'];
if ($number!=NULL) {
if ($genarray['money']>=($cost*$numbe r)) {
settype($purcha se, "float");
$purchase=$cost *$number;
round($purchase , 2);
mysql_query("UP DATE `users` WHERE `id`='$id' SET `towns`=`towns` +'$number'");
echo "
<script language=\"java script\" type=\"text/javascript\">al ert(\"Town built successfully.\" )
parent.location =\"viewempire.p hp\"</script>";
} else {
echo "
<script language=\"java script\" type=\"text/javascript\">al ert(\"Not enough funds!!\")</script>";
}
}
?>[/PHP]
buytown.php
[PHP]
<?php
session_start() ;
//$_SESSION['user'] is the logged-in user's id number used to get data.
echo "<head>
<title>Empire z! 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($_SESSI ON['user'])) {
echo "<script language=\"java script\" type=\"text/javascript\">al ert(\"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_qu ery("SELECT * FROM `users` WHERE `id`='$id'");
$genarray=mysql _fetch_array($q uery); //General info array
settype($townco st, "float"); //Float the town cost
settype($genarr ay['money'], "float");
$towncost=($gen array['towns']*2800)/3; //Calculate the cost per town
$cost=round($to wncost, 2); //Round the town costs
include ("server/buytown.post.ph p");
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=\"Purchas e\">
<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.ph p
[PHP]<?php
$number=$_POST['number'];
if ($number!=NULL) {
if ($genarray['money']>=($cost*$numbe r)) {
settype($purcha se, "float");
$purchase=$cost *$number;
round($purchase , 2);
mysql_query("UP DATE `users` WHERE `id`='$id' SET `towns`=`towns` +'$number'");
echo "
<script language=\"java script\" type=\"text/javascript\">al ert(\"Town built successfully.\" )
parent.location =\"viewempire.p hp\"</script>";
} else {
echo "
<script language=\"java script\" type=\"text/javascript\">al ert(\"Not enough funds!!\")</script>";
}
}
?>[/PHP]
Comment