Jump to content

McBryver

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

McBryver's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello I am trying to get an action status based on e.g attackers_1 troops. Unfortunately I get nothing when I die the $strikeaction var here is my function and method I use to call it. <?php function getStrikeAction($id){ $q = "SELECT * FROM `accountinfo_db` WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); $player = mysql_fetch_array($res); if($player['siegetech']>=1){ $strikeaction=($player['attackers_1'] * $player['siegetech'] * 120); $strikeaction+=($player['attackers_2'] * $player['siegetech'] * 1200); $strikeaction+=($player['attackers_3'] * $player['siegetech'] * 80); }else{ $strikeaction=($player['attackers_1'] * 120); $strikeaction+=($player['attackers_2'] * 1200); $strikeaction+=($player['attackers_3'] * 80); } $id = $player['id']; $q = "UPDATE `accountinfo_db` SET `strikeaction` = '$strikeaction' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); return $stikeaction; } ?> <?php echo getStrikeAction($player['id']);?>
  2. Ok here is what I get from that: Array ( [miner>] => 1 [atsold] => 0 [defsold] => 0 [spy] => 0 [spykiller] => 0 [untrain] => UnTrain! )
  3. Hello, My script here is not sending POST vars from form to script. I can't figure it out. Form: <form action="train2.php" method="POST"> <tr> <td colspan="4"><center><img src="pic/toppage16.gif" /></center></td> </tr> <TR> <TD><FONT COLOR="white">Reassign Miners</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength="8" value="0" name="miner>"</FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Normal Attackers</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength="8" value="0" name="atsold"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Normal Defenders</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size=6 maxlength=8 value=0 name="defsold"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Covert Agents</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size=6 maxlength=8 value=0 name="spy"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Anti Covert Agents</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD><TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength=8 value=0 name="spykiller"></FONT></TD></TR> <TR> <TD align=middle colSpan=3><FONT COLOR="white"><INPUT type="submit" value="UnTrain!" name="untrain"> </FONT> </TD> </form> <?php if(isset($_POST['untrain'])){ die($_POST['miner']); $miners = securevar($_POST['miner']); $nattackers = securevar($_POST['atsold']); $ndefenders = securevar($_POST['defsold']); $covertunits = securevar($_POST['spy']); $anticovertunits = securevar($_POST['spykiller']); $totalunits+=$miners; $totalunits+=$nattackers; $totalunits+=$ndefenders; $totalunits+=$covertunits; $totalunits+=$anticovertunits; if($totalunits>=1){ $q = "UPDATE `accountinfo_db` SET `miners_1` = `miners_1`-'$miner', `attackers_1` = `attackers_1`-'$natta', `defenders_1` = `defenders_1`-'$ndefe', `covertagents` = `covertagents`-'$cover', `anticovertagents` = `anticovertagents`+'$antic', `untrainedunits` = `untrainedunits`+'$totalunits' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ header("Location: train.php?strmsg=".$totalunits."Troops Untrained! For 0 Naquadah."); } }else{ header("Location: train.php?strmsg=You must enter atleast 1 troop to be un-trained!"); } } ?> when I die($_GET['miner'); nothing is outputed even tho I submited the data. Thank you, Brian
  4. Let me try to re-explain: if User 1's covertaction is 900,000 and User 2's covertaction is 900,100 and User 3's covertaction is 900,200 Rank User 1 as Rank 3 Rank User 2 as Rank 2 Rank User 3 as Rank 1 Hopefully this helps.
  5. Hello everyone... My following code is supposed to order rank by from Greatest covertaction but for some reason it is ranking the greatest last eg. 900,000 Rank 1 900,001 Rank 2 900,002 Rank 3 Here is the code: <?php $q = "SELECT * FROM `accountinfo_db` ORDER BY `covertaction`, `anticovertaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $i = 1; while($player=mysql_fetch_array($res)){ $id = securevar($player['id']); $time = time(); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `covertrank` = '$i', `lastTurnTime` = '$time' WHERE `id` = '$id'"; if(mysql_query($q)){ echo "Covert & Anti Covert Rank set to $user as ".number_format($i)."!<br />"; } else { // query failed with an error // put your error reporting/logging code here... } $i++; } ?> Any help will be appreciated! Brian
  6. I cannot find the Mark Solved button so Mods delete this!
  7. Thank you very much topic solved and I am confident that I can modify this with no problem.
  8. Tried to use mysql_fetch_row and it gave me a similar error.
  9. Ok great thank you PFMaBiSmAd it works and ranks my players Altho I get this error: Strike Rank set to Photonic as 1! Warning: mysql_fetch_array(): 5 is not a valid MySQL result resource in C:\xampp\htdocs\GMAE\getNextTurn.php on line 10 Defence Rank set to Photonic as 1! Defence Rank set to Joe as 2! Covert & Anti Covert Rank set to Photonic as 1! Covert & Anti Covert Rank set to Joe as 2! Mothership Rank set to Photonic as 1! Mothership Rank set to Joe as 2! Overall Rank set to Photonic as 1! Overall Rank set to Joe as 2! Also I added a <br /> to the end of each echo.
  10. Ok as for the for loop it indicates the times the loop runs so that it can add a rank according to the time the loop has been ran. I have changed the outer $res from the $res in the loop: $q = "SELECT * FROM `accountinfo_db` ORDER BY `strikeaction` ASC";//Select all from account table order by strike action ascending . $res2 = mysql_query($q) or die(mysql_error()); // Query $count = mysql_num_rows($res2); // Count while($player=mysql_fetch_row($res2)){ // While Loop for($i=1;$i>=$count;$i++){// For loop mysql_free_result($res2); $id = securevar($player['id']); // ID $user = securevar($player['username']); // Username $q = "UPDATE `accountinfo_db` SET `strikerank` = '$i' WHERE `id` = '$id'"; // Update account set strike action equals $i where account is account. $res = mysql_query($q) or die(mysql_error()); // Get Query // if isset result from query. mysql_free_result($res); echo "Strike Rank set to $user as ".number_format($i)."!"; // Echo This. } } But nothing has changed still white page. Brian Thanks thus far....
  11. I have been reading posts on other forums that have to do with the Resource id #5 and have found in a few cases they used: mysql_fetch_assoc() how can I use this in my case if possible?
  12. Ive never seen anything like this again thanks for any help whether or not It does any good.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.