seany123 Posted May 2, 2009 Share Posted May 2, 2009 can anyone someone please help me.. I am doing a battle page for my game. i am getting the output... but its not doing any of the 4 queries <?php else if ($enemy->hp <= 0) //PLAYER WINS { //Calculate losses $expwin = ($enemy->level - $player->level * 100 + 100); if($expwin <= 1) { $expwin = rand(1, 10); } $moneywin = intval($enemy->money * 0.05); $output .= "<br />You attacked " . $enemy->username . " and won.<br />"; $output .= "<br />You gained <b>" . $expwin . "</b> EXP and <b>$" . $moneywin . "</b>."; $newexp = $exploss + $enemy->exp - $enemy->maxexp; //Update Enemy (THE LOSER) $query = $db->execute("update `players` set `money`=?, `battle_loss`=?, `battle_total`=?, `battle_money`=?, `hospital`=20 where `id`=?", array($enemy->money - $moneywin, $enemy->battle_loss + 1, $enemy->battle_total + 1, $enemy->battle_money - $moneywin, $enemy->id)); $logmsg = "You were attacked by <a href=\"profile.php?id=" . $player->username . "\">" . $player->username . "</a> and lost<br />\nYou lost $" . $moneyloss .""; addlog($enemy->id, $logmsg, $db); //Update player (the winner). if ($expwin + $player->exp < $player->maxexp) { $query = $db->execute("update `players` set `exp`=?, `money`=?, `battle_won`=?, `battle_total`=?, `battle_total`, `hp`=? where `id`=?", array($player->exp + $exploss, $player->money + $moneyloss, $player->battle_won + 1, $player->battle_total + 1, $player->battle_money + $moneyloss, $player->hp, $player->id)); } // MAX LEVEL (NO EXP). if ($player->exp + $expgain >= $player->maxexp && $player->level >= $player->maxlevel) { $query = $db->execute("update `players` set `money`=?, `exp`=?, `battle_won`=?, `battle_total`=? `battle_money`=? where `id`=?", array($player->money + $moneywin, $player->exp + $expwin, $player->battle_won + 1, $player->battle_total + 1, $player->battle_money + $moneyloss, $player->id )); } // GAINED A LEVEL. if ($player->exp + $expgain >= $player->maxexp && $player->level < $player->maxlevel) { $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `battle_won`=?, `battle_money`=?, `battle_total`=?, `maxnerve`=? where `id`=?",array(1, $maxexpgain, $newexp, $player->money + $moneywin, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->battle_won + 1, $player->battle_money + $moneywin, $player->battle_total + 1, $player->maxnerve + 1, $player->id)); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/ Share on other sites More sharing options...
Ken2k7 Posted May 2, 2009 Share Posted May 2, 2009 I wonder who taught people to use ? as placeholders for values. Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/#findComment-824519 Share on other sites More sharing options...
Philip Posted May 2, 2009 Share Posted May 2, 2009 Are you using a custom DB class, or trying to use mysqli? If it's custom, please post the full class EDIT: I read in your other post - see here for manual doc: http://phplens.com/lens/adodb/docs-adodb.htm#execute and... http://phplens.com/lens/adodb/docs-adodb.htm#ex4 Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/#findComment-824526 Share on other sites More sharing options...
seany123 Posted May 4, 2009 Author Share Posted May 4, 2009 ive looked at the two links, i cant see where it tell me why the queries wouldnt be run. Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/#findComment-825853 Share on other sites More sharing options...
seany123 Posted May 4, 2009 Author Share Posted May 4, 2009 please can anyone see any errors or problems with this code? the queries arnt running but the outputs are. Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/#findComment-826074 Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 Read KingPhilip's reply. We can't find out what's happening because your queries are executing within a db class method. You probably want to post that method here if you want us to look further. Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/#findComment-826079 Share on other sites More sharing options...
ionik Posted May 4, 2009 Share Posted May 4, 2009 What do you get when the queries are run are there any error messages, and are you sure that those if statements are properly working? Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/#findComment-826091 Share on other sites More sharing options...
Philip Posted May 4, 2009 Share Posted May 4, 2009 You should probably add this after you include the db file. $db->debug = true; This will now display the SQL statement before your executions, and also show any pesky error messages. Quote Link to comment https://forums.phpfreaks.com/topic/156593-help-me-please/#findComment-826150 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.