Hi
I have an online game, and I have a problem with one of my functions for a 'guild' which is built into the game itself. Its a text based game.
To keep it simple, when they join a guild, they pay in "dscales" and the field name is named the same as that. These dscales come from the users table, and then added to the guilds table.
Im simply have a small problem with when the dscales comes from the users table, and then into the guilds, it resets the guilds dscales field completely back to 0, along with adding the amount of required dscales to that 0. It is coming from the users table correctly, but its having difficulties being added to the guilds table, without it resetting. I was wondering whether anyone nice could help? I hope all this makes sense since its hard to explain.
Here is the code:
function dosignup($guildid) {
global $userrow;
$joinquery = doquery("SELECT * FROM {{table}} WHERE id='".$guildid."' LIMIT 1", "guilds");
$joinrow = mysql_fetch_array($joinquery);
if ($userrow["dscales"] < $joinrow["joincost"]) { display("<table width=\"100%\"><tr><td class=\"title\">Joining a Guild</td></tr></table>You do not have enough Dragon Scales to join the ".$joinrow["name"].".<br /><br />You may return to the <a href='index.php'>town</a>, or leave and continue exploring using the compass to the right.", "Join a Guild"); die(); }
if (isset($_POST["submit"])) {
$joincost = $_POST["joincost"];
$newdscales = $userrow["dscales"] - $joincost;
$guildname = $_POST["name"];
$guildid = $_POST["guildid"];
$founder = $_POST["founder"];
$title = "Joining a Guild";
$page = "<table width=\"100%\"><tr><td class=\"title\">Joining a Guild.</td></tr></table>";
$page .= "You have officially joined the ".$guildname." Guild.<br />";
$page .= "<br />You may return to the <a href='guilds.php'>Guild Courtyard</a>,";
$page .= " or leave and ";
$page .= "<a href='index.php'>or return to town</a>.";
$guildrank = 0;
if ($founder == $userrow["charname"]) {$guildrank = 250;}
$q = doquery("UPDATE {{table}} SET dscales='$newdscales',guildname='$guildname',guildrank='$guildrank' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
$dscales = $joincost;
$query = doquery("UPDATE {{table}} SET dscales='$dscales' WHERE id='".$guildid."' LIMIT 1", "guilds");
This is just small section of the code
Thanks, its really appreciated if you can help pinpoint the problem.