Jump to content

McBryver

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by McBryver

  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.
  13. Ok mr pikachu I changed the AND to commas. Still no change from white page. Here is the new code : <?php include("secure/database.php"); // Include Database Connection File... $q = "SELECT * FROM `accountinfo_db` ORDER BY `strikeaction` ASC";//Select all from account table order by strike action ascending . $res = mysql_query($q) or die(mysql_error()); // Query $count = mysql_num_rows($res); // Count for($i=1;$i>=$count;$i++){// For loop while($player=mysql_fetch_array($res)){ // While Loop mysql_free_result($res); $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($res)){ // if isset result from query. mysql_free_result($res); echo "Strike Rank set to $user as ".number_format($i)."!"; // Echo This. } } } $q = "SELECT * FROM `accountinfo_db` ORDER BY `defenceaction` ASC"; // Select all from table order by defenceaction ascending. $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ mysql_free_result($res); $id = securevar($player['id']); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `defencerank` = '$i' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ mysql_free_result($res); echo "Defence Rank set to $user as ".number_format($i)."!"; } } } $q = "SELECT * FROM `accountinfo_db` ORDER BY `covertaction`, `anticovertaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ mysql_free_result($res); $id = securevar($player['id']); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `covertrank` = '$i' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ mysql_free_result($res); echo "Covert & Anti Covert Rank set to $user as ".number_format($i)."!"; } } } $q = "SELECT * FROM `accountinfo_db` ORDER BY `msaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ mysql_free_result($res); $id = securevar($player['id']); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `msrank` = '$i' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ mysql_free_result($res); echo "Mothership Rank set to $user as ".number_format($i)."!"; } } } $q = "SELECT * FROM `accountinfo_db` ORDER BY `msaction`, `strikeaction`, `defenceaction`, `covertaction`, `anticovertaction`, `msaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ mysql_free_result($res); $id = securevar($player['id']); $user = securevar($player['username']); $time = time(); $q = "UPDATE `accountinfo_db` SET `rank` = '$i', `lastTurnTime` = '$time' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ mysql_free_result($res); echo "Overall Rank set to $user as ".number_format($i)."!"; } } } ?>
  14. Ok what I am trying to do is set the rank of each user by order of how it is grabbed by the query if users are grabbed like this: user 2 Set Rank to 1 user 3 Set Rank to 2 user 1 Set Rank to 3 hopefully this helps Pikachu2000 brian
  15. Ok I died out $res and get: Resource id #5 I am currently hitting google hard. Still no close to figuring this out. Btw Here is my Database Connection file: <?php session_start(); // Variable Overview $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'carpodiem'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); $dbname = 'database_info'; mysql_select_db($dbname); include("secure/mainfuncs.php"); ?> Thank you. Brian
  16. Ok when I run this code is displays nothing but a white page.. No error or anything. I have commented the first two segments of code the rest should be self explainable. Ok my beauty of a script: Any help to improve and or modify would be great as well as helping with the problem at hand. <?php include("secure/database.php"); // Include Database Connection File... $q = "SELECT * FROM `accountinfo_org` ORDER BY `strikeaction` ASC";//Select all from account table order by strike action ascending . $res = mysql_query($q) or die(mysql_error()); // Query $count = mysql_num_rows($res); // Count for($i=1;$i>=$count;$i++){// For loop while($player=mysql_fetch_array($res)){ // While Loop $id = securevar($player['id']); // ID $user = securevar($player['username']); // Username $q = "UPDATE `accountinfo_org` 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($res)){ // if isset result from query. echo "Strike Rank set to $user as ".number_format($i)."!"; // Echo This. } } } $q = "SELECT * FROM `accountinfo_org` ORDER BY `defenceaction` ASC"; // Select all from table order by defenceaction ascending. $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ $id = securevar($player['id']); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `defencerank` = '$i' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ echo "Defence Rank set to $user as ".number_format($i)."!"; } } } $q = "SELECT * FROM `accountinfo_org` ORDER BY `covertaction` AND `anticovertaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ $id = securevar($player['id']); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `covertrank` = '$i' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ echo "Covert & Anti Covert Rank set to $user as ".number_format($i)."!"; } } } $q = "SELECT * FROM `accountinfo_org` ORDER BY `msaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ $id = securevar($player['id']); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `msrank` = '$i' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ echo "Mothership Rank set to $user as ".number_format($i)."!"; } } } $q = "SELECT * FROM `accountinfo_org` ORDER BY `msaction` AND `strikeaction` AND `defenceaction` AND `covertaction` AND `anticovertaction` AND `msaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $count = mysql_num_rows($res); for($i=1;$i>=$count;$i++){ while($player=mysql_fetch_array($res)){ $id = securevar($player['id']); $user = securevar($player['username']); $time = time(); $q = "UPDATE `accountinfo_db` SET `rank` = '$i', `lastTurnTime` = '$time' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ echo "Overall Rank set to $user as ".number_format($i)."!"; } } } ?> Brian
  17. I am using some sort of free hosting so I do not have access to the php.ini file and I have tried to echo and die the data but it does not display anything, also it works fine on my xampp local testing server but not on the hosting. I think I might need to find some other hosting service. Does anyone know of a good free hosting service with instant activation and usage? Thank you for the help, Brian
  18. Hello everyone, When I submit my login form to go to my login page it goes to a white page and does not display an error. <?php include("../secure/database.php"); if(!empty($_POST['loginsubmit'])){ if(!empty($_POST['email'])){ $email = securevar($_POST['email']); if(!empty($_POST['passconf'])){ $pass = securevar($_POST['passconf']); $q = "SELECT * FROM `accountinfo_db` WHERE `email` = '$email' AND `password` = '$pass'"; $res = mysql_query($q) or die(mysql_error()); $login = mysql_fetch_array($res); $id = $login['id']; $active = $login['active']; if($id>=1){ if($active==1){ $_SESSION['logged'] = $login['id']; $q = "UPDATE `accountinfo_db` SET `loggedtimes` = `loggedtimes`+'1' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); $user = $login['username']; header("Location: ../mainframe.php?strmsg=Welcome Back $user"); }else{ header("Location: activate.php"); } }else{ header("Location: ../index.php?strmsg=Login Information Incorrect!"); } }else{ header("Location: ../index.php?strmsg=You did not enter a valid password!"); } }else{ header("Location: ../index.php?strmsg=You did not enter a valid email!"); } }else{ header("Location: ../index.php?strmsg=We are sorry but you are not allowed viewance of that directory!"); } ?> any help would be great. Brian
  19. Ok I got IE's Error Display up and the only error it finds is one associated with the jquery involved in opening a popup that displays the reg form information this is the code that it says is erroring: <script type="text/javascript"> $(document).ready(function() { //When you click on a link with class of poplight and the href starts with a # $('a.poplight[href^=#]').click(function() { var popID = $(this).attr('rel'); //Get Popup Name var popURL = $(this).attr('href'); //Get Popup href to define size //Pull Query & Variables from href URL var query= popURL.split('?'); var dim= query[1].split('&'); var popWidth = dim[0].split('=')[1]; //Gets the first query string value //Fade in the Popup and add close button $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="images/close.png" class="btn_close" title="Close Window" alt="Close" /></a>'); //Define margin for center alignment (vertical horizontal) - we add 80px to the height/width to accomodate for the padding and border width defined in the css var popMargTop = ($('#' + popID).height() + 80) / 2; var popMargLeft = ($('#' + popID).width() + 80) / 2; //Apply Margin to Popup $('#' + popID).css({ 'margin-top' : -popMargTop, 'margin-left' : -popMargLeft }); // Error line located here, but it says char 69 and there aren't that many characters on this line. //Fade in Background $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag. $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies return false; }); //Close Popups and Fade Layer $('a.close, #fade').live('click', function() { //When clicking on the close or fade layer... $('#fade , .popup_block').fadeOut(function() { $('#fade, a.close').remove(); //fade them both out }); return false; }); }); </script> I added a comment where the error is located. Please help.
  20. Ok I unchecked the disable debugging things in IE's advanced options how do I view the errors detected?
  21. Whats not working is the sendships function and the getRaceInfo function <form name="reg" id="reg"> <input type="hidden" id="racereal" name="racereal" value="" /> </form> <div id="register" class="popup_block" align="center" style="opacity:0.8;"> <h2>Register for Blah Blach Bue!</h2> <p><div id="race_info" style=" align:left;"></div></p> <p><div id="reg_error" style="color: red;"></div></p> <p>Username:</p> <p> <input type="text" name="user" id="user"/></p> <p>Race:</p> <p><select> <option>Select a Race!</option> <option value="1" name="race1" id="race1" onclick="return getRaceInfo(1);">Praline Empire</option> <option value="2" name="race2" id="race2" onclick="return getRaceInfo(2);">Human Federation</option> <option value="3" name="race3" id="race3" onclick="return getRaceInfo(3);">Nukari Coalition</option> <option value="4" name="race4" id="race4" onclick="return getRaceInfo(4);">Creatarian Empire</option> </select> <p>Password</p> <p><input type="password" name="pass" id="pass"/><br /></p> <p>Planet Name</p> <p><input type="text" name="pname" id="pname" value="Homeworld"/><br /></p> <p>Email</p> <p><input type="text" name="email" id="email"/><br /></p> <p>Confirm Email</p> <p><input type="text" name="email2" id="email2"/><br /></p> <p>Security Code</p> <p><input type="text" value="" name="security_code" id="security_code"></p> <p><img src="imagescript.php"/><br /></p> <p><div class="button"><a onclick='javascript:register()' style='cursor: pointer;'>Register!</a></div></p> </div> </div> <script type="text/javascript"> function getRaceInfo(race){ if(race == 1){ document.reg.racereal.value = race; document.getElementById("race_info").innerHTML = "<img src='images/praline.gif' /><br /><h4>Free Praline Empire Account!</h4> <p>25% Attack Bonus</p><p>25% Espionage Bonus</p><br />"; } if(race == 2){ document.reg.racereal.value = race; document.getElementById("race_info").innerHTML = "<img src='images/human.gif' /><br /><h4>Free Human Federation Account!</h4><p>25% Income Bonus</p><p>25% Defence Bonus</p><br />"; } if(race == 3){ document.reg.racereal.value = race; document.getElementById("race_info").innerHTML = "<img src='images/nukari.gif' /><br /><h4>Free Nukari Coalition Account!</h4><p>25% Espionage Bonus</p><p>25% Income Bonus</p><br />"; } if(race == 4){ document.reg.racereal.value = race; document.getElementById("race_info").innerHTML = "<img src='images/cretarian.gif' /><br /><h4> FreeCretarian Empire Account!</h4><p>25% Attack Bonus</p><p>25% Defence Bonus</p><br />"; } } </script> and <script type="text/javascript"> function stopShipSend(){ document.getElementById("sendships").innerHTML = ""; } function sendships(){ var div = '<form method="POST" action="sendships.php"><p align="center">Cargo Ship(100) <input type="text" name="cargoship_send" value="0" /></p> <p align="center">Large Cargo Ship(100) <input type="text" name="cargoship_send" value="0" /></p> <p align="center">Short Range Fighters(100) <input type="text" name="cargoship_send" value="0" /></p> <p align="center">Long Range Fighters(100) <input type="text" name="cargoship_send" value="0" /></p><p align="center">Colony Ships(100) <input type="text" name="cargoship_send" value="0" /></p><p align="center">Battle Crusiers(100) <input type="text" name="cargoship_send" value="0" /></p><p align="center"><input type="checkbox" value="false" name="attack"> Attack Mission</p><p align="center"><input type="checkbox" name="defend" value="true" checked /> Defend This Planet</p><p align="center"><input type="submit" value="Run Mission" name="runm" style="cursor:pointer;" /> | <a href="javascript:stopShipSend();">Cancel Mission</a></p></form>' document.getElementById("sendships").innerHTML=div; } </script> <div id="sendships"> </div> <p align="center"> <?php if($colony['id']!=$row['id']){?> <select name="mission" id="mission"> <option>Mission</option> <option style="cursor: pointer;" onclick="return sendships();">Send Ships</option> <option>Send Troops</option> <option>Send Espionage Probes</option> <option>Make War</option> <option>Make Peace!</option> </select> <?php /* <input type="submit" style="cursor: pointer;" onclick="return sendships();" value="Mission:Send Ships!" />| <input type="submit" style="cursor: pointer;" value="Mission:Send Troops!" />| <input type="submit" style="cursor: pointer;" value="Mission:Send Espionage Probes!" />| <input type="submit" style="cursor: pointer;" value="Mission:Make War!" />| <input type="submit" style="cursor: pointer;" value="Mission:Make Peace!" /> */ ?> <?php } ?> </p> Any help would be nice thanks, Brian.
×
×
  • 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.