The code below is not working properly and a little help from the DP community cleaning it up and explaining why you would change certain areas would help me greatly. Thank you in advance function treasury() { // Treasury Info. global $userrow, $numqueries; $bankquery = doquery("SELECT username FROM sw_users WHERE id='".$userrow["id"]."' LIMIT 1", "users"); if (mysql_num_rows($bankquery) != 1) { display("Cheat attempt detected.<br /><br />Your username has been logged ... consider this a warning.", "Error"); } $bankrow = mysql_fetch_array($bankquery); if (isset($_POST["submit"])) { $newgold = $userrow["gold"] - $userrow["gold"]; $query = doquery("UPDATE sw_users SET gold='$newgold',bank='".$userrow["bank"] + '$newgold'."' WHERE id='".$userrow["id"]."' LIMIT 1", "users"); $title = "Treasury"; $page = "You leave the Treasury feeling safe that Your hard earned gold is protected.<br /><br />You may return to <a href=\"index.php\">town</a>, or use the direction buttons on the left to start exploring."; } elseif (isset($_POST["cancel"])) { header("Location: index.php"); die(); } else { $title = "Treasury"; $page = "Placing gold in the treasury will keep it safe from Monsters and other Players.<br />You currently must deposit all Gold.<br /><br />\n"; $page .= "You Currently have <b>". $bankrow['bank'] ." gold</b> in the Treasury at this time.<br /><br />\n"; $page .= "<form action=\"index.php?do=treasury\" method=\"post\">\n"; $page .= "<input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" />\n"; $page .= "</form>\n"; } display($page, $title); } Code (markup): I am new at functions so any input would help me greatly
Okay I will be more specific where my initial problem is here is the code followed by the problem: global $userrow, $numqueries; $bankquery = doquery("SELECT username FROM sw_users WHERE id='".$userrow["id"]."' LIMIT 1", "users"); if (mysql_num_rows($bankquery) != 1) { display("Cheat attempt detected.<br /><br />Your username has been logged ... consider this a warning.", "Error"); } $bankrow = mysql_fetch_array($bankquery); $page .= "You Currently have <b>". $bankrow["bank"] ." gold</b> in the Treasury at this time.<br /><br />\n"; Code (markup): ". $bankrow["bank"] ." <---Displays nothing not even a 0 or error?
$bankquery = doquery("SELECT username FROM sw_users WHERE id='".$userrow["id"]."' LIMIT 1", "users"); You are only requesting the username from the database.