Dethman Posted July 14, 2008 Share Posted July 14, 2008 Hey guys I have just finished with this code and everything plays out accept this: Note The Adding of +{$def} Is working Fine... <?php //Actuall MySql_Query: mysql_query("UPDATE `user_users` SET `credits` =(`credits` -{$cost}), `attackTroops` =(`attackTroops` +{$atk}-{$satk}), `atkTroops` =(`atkTroops` +{$satk}), `defenseTroops` =(`defenseTroops` +{$def}-{$sdef}),`defTroops` =(`defTroops` +{$sdef}), `covertTroops` = (`covertTroops` +{$spy}), `wizzards` =(`wizzards` +{$wiz}), `farmer` =(`farmer` +{$far}), `miner` = (`miner` +{$cre}), `untrainedTroops` =(`untrainedTroops` - {$atk}-{$def}-{$spy}-{$wiz}-{$far}-{$cre}) WHERE `userid` = '$userid'") or die("SQL Error: ".mysql_error()); //Line that isnt working: `defenseTroops` =(`defenseTroops` +{$def}-{$sdef}),`defTroops` =(`defTroops` +{$sdef}), ?> Entire Code: <?php function spyBoost($cost,$id){ $q="UPDATE `user_users` SET `credits` =`credits` - '$cost', `covertLVL` = `covertLVL` +'1' WHERE `userid` = '$id'"; mysql_query($q); header("Location: train.php?strErr=Covert Level Upgraded"); } function birthBoost($amt,$cost,$id){ $q="UPDATE `user_users` SET `credits` =`credits` - '$cost', `birthrate` = `birthrate` +'$amt' WHERE `userid` = '$id'"; mysql_query($q); header("Location: train.php?strErr=Birth Rate Upgraded"); } function trainTroops($atk,$satk,$def,$sdef,$spy,$wiz,$far,$cre,$userid){ $sql="SELECT * FROM `user_users` WHERE `userid` = '$userid'"; $query=mysql_query($sql); $player=mysql_fetch_array($query); $atk=floor($atk); $satk=floor($satk); $def=floor($def); $sdef=floor($sdef); $spy=floor($spy); $wiz=floor($wiz); $far=floor($far); $cre=floor($cre); if($cre<=0){ $cre=0; } if($far<=0){ $far=0; } if($wiz<=0){ $wiz=0; } if($spy<=0){ $spy=0; } if($sdef<=0){ $sdef=0; } if($def<=0){ $def=0; } if($satk<=0){ $satk=0; } if($atk<=0){ $atk=0; } if($player['untrainedTroops']-($atk+$satk+$def+$sdef+$spy+$wiz+$far+$cre)>=0){ if($player['attackTroops']-$satk >=0){ if($player['defenseTroops']-$sdef >=0){ if($player['credits']-((($atk+$def)*3000)+($spy*5000)+($satk+$sdef*89000)+($wiz*5500)+($far*5000)+($cre*1500))>=0){ $cost=$spy*5000; $cost+=($atk+$def)*3000; $cost+=($satk+$sdef)*89000; $cost+=$wiz*5500; $cost+=$far*5000; $cost+=$cre*1500; mysql_query("UPDATE `user_users` SET `credits` =(`credits` -{$cost}), `attackTroops` =(`attackTroops` +{$atk}-{$satk}), `atkTroops` =(`atkTroops` +{$satk}), `defenseTroops` =(`defenseTroops` +{$def}-{$sdef}),`defTroops` =(`defTroops` +{$sdef}), `covertTroops` = (`covertTroops` +{$spy}), `wizzards` =(`wizzards` +{$wiz}), `farmer` =(`farmer` +{$far}), `miner` = (`miner` +{$cre}), `untrainedTroops` =(`untrainedTroops` - {$atk}-{$def}-{$spy}-{$wiz}-{$far}-{$cre}) WHERE `userid` = '$userid'") or die("SQL Error: ".mysql_error()); header("Location: train.php?strErr=TRAINING SUMMARY<br>Troops Trained!"); }else{ header("Location: train.php?strErr=TRAINING SUMMARY<br>Not Enough Magi!"); } } else{ header("Location: train.php?strErr=TRAINING SUMMARY<br>You Need Enouph Attackers to Train that Many Supers"); } }else{ header("Location: train.php?strErr=TRAINING SUMMARY<br>You Need Enouph Attackers to Train that Many Supers"); } }else{ header("Location: train.php?strErr=TRAINING SUMMARY<br>Not Enough Civillians"); } } function untrainTroops($atk,$def,$spy,$userid){ $sql="SELECT * FROM `user_users` WHERE `userid` = '$userid'"; $query=mysql_query($sql); $user=mysql_fetch_array($query); $atk=floor($atk); $def=floor($def); $spy=floor($spy); if($spy<=0){ $spy=0; } if($def<=0){ $def=0; } if($atk<=0){ $atk=0; } if($user['untrainedTroops']-($atk+$def+$spy)>=0){ if($user['credits']-((($atk+$def)*000)+($spy*000))>=0){ $cost=$spy*000; $cost+=($atk+$def)*000; mysql_query("UPDATE `user_users` SET `credits` = `credits` - '$cost', `attackTroops` = `attackTroops` -'$atk', `defenseTroops` = `defenseTroops` -'$def', `covertTroops` = `covertTroops` -'$spys', `untrainedTroops` = `untrainedTroops` + '$atk'+'$def'+'$spy' WHERE `userid` = '$userid'"); header("Location: train.php?strErr=troops trained"); }else{ header("Location: train.php?strErr=not enough credits"); } }else{ header("Location: train.php?strErr=not enough civillians"); } } ?> Please help this thing is getting annoying.... Thanks for all of your help, Brian Flores CEO NimbusGames,llc Link to comment https://forums.phpfreaks.com/topic/114664-solved-troop-wont-train/ Share on other sites More sharing options...
Dethman Posted July 14, 2008 Author Share Posted July 14, 2008 Hopefully you guys dont get upset its been like 5 or 6 hours since I posted.... But I am Bumping this Post! Link to comment https://forums.phpfreaks.com/topic/114664-solved-troop-wont-train/#findComment-589944 Share on other sites More sharing options...
Barand Posted July 14, 2008 Share Posted July 14, 2008 http://www.phpfreaks.com/forums/index.php/topic,206713.msg938532.html#msg938532 and then you go and post saying "it isn't working" Link to comment https://forums.phpfreaks.com/topic/114664-solved-troop-wont-train/#findComment-589966 Share on other sites More sharing options...
Dethman Posted July 14, 2008 Author Share Posted July 14, 2008 What do you mean... Link to comment https://forums.phpfreaks.com/topic/114664-solved-troop-wont-train/#findComment-589976 Share on other sites More sharing options...
Barand Posted July 14, 2008 Share Posted July 14, 2008 you complain that one poster hasn't give enough info and then you post, show some code, and say "it isn't working". How about some information from yourself Define "not working" What is it doing that id shouldn't? What isn't it doing that it should? You know, give us a clue. Link to comment https://forums.phpfreaks.com/topic/114664-solved-troop-wont-train/#findComment-590007 Share on other sites More sharing options...
Dethman Posted July 14, 2008 Author Share Posted July 14, 2008 I fixed the code.... Link to comment https://forums.phpfreaks.com/topic/114664-solved-troop-wont-train/#findComment-590016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.