MasterACE14 Posted April 26, 2009 Share Posted April 26, 2009 One user out of about 300 on my website is getting blank white pages on a few different pages on my website when logged in. The page is completely blank and white, however the code is still executing because the database values do change as they should when forms are submitted. Everything works fine for all the other users, so I can't see how it could be a parse error, warning, notice or mysql error. I'm at a total loss. Any help is appreciated. Regards, ACE Quote Link to comment Share on other sites More sharing options...
Axeia Posted April 26, 2009 Share Posted April 26, 2009 Ask the user for details on his browser/OS and exactly what he types in / buttons that are pressed. If it goes fine and only one person is seeing white page he/she is obviously either doing something differently or use a setup different from the rest. Also ensure that you're using valid HTML, as I suspect it's some browser rendering bug caused by buggy HTML. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted April 26, 2009 Share Posted April 26, 2009 Turn on error logging to a file and see if something comes up. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 26, 2009 Share Posted April 26, 2009 Application logging really helps out when you are bug fixing a live site. start recording browser info as Aexia suggests. You could also cache the pages being served out to this user - opening them up in your own browser to see if you can replicate (you should perhaps use some VM ware to truly replicate their environment). In this case as only one user has an issue just log based on their userid... Post back if you need tips on what to log. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted April 28, 2009 Author Share Posted April 28, 2009 in the error_log file, everytime my user encounters a white page. This is what is logged in it. [27-Apr-2009 23:44:29] PHP Fatal error: Out of memory (allocated 45088768) (tried to allocate 35 bytes) in /home/eliteace/public_html/realmbattles/vsys.php on line 378 any idea's on how to fix this? cheers. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 28, 2009 Share Posted April 28, 2009 Fatal runtime errors mean fatal. Execution stops at that point, php executes the page destructor cleanup code and stops. It would take knowing what your code on that page is doing. It either requires more memory than is available or it contains a logic error that continually consumes memory in a loop until all available memory has been used. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted April 28, 2009 Author Share Posted April 28, 2009 any particular reason why only one user would be getting this? and not all users? Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted April 28, 2009 Share Posted April 28, 2009 That's difficult to say, but try to look at where the log entry says the error occurred. Maybe that'll help you. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 28, 2009 Share Posted April 28, 2009 It would take knowing what your code on that page is doing. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 29, 2009 Share Posted April 29, 2009 you MUST sanitize any data you collect from a user. If this is particular to one user check and see what is unique about that user - it could be something stored in the session like a character that causes the problem... Memory allocation problems are often caused by recursive execution of code - it could be that this one users is experiencing this - maybe an include is cycling by calling a page that is already been called. if possible switch and require/include to require_once or include once. You could get the users details and test locally - debugging script by inserting various echo statements and exit(); to stop execution at strategic points (not the best way to debug but if you don't have any other tool available and don't want xdebug then it could be good for you - I learn't a fair bit debugging this way in the early days ) good luck and keep posting back any updates. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted April 30, 2009 Author Share Posted April 30, 2009 It appears several more users have been having the same problem, and have only just reported it now. The problems only seem to have started when I released the next version of my game. So the past few days I've been running through my code seeing where I may have slipped up with a loop, undeclared variables, PHP Warnings the works. I came to the conclusion that the out of memory error may have been caused by the HTML compression I added. // compress HTML //ob_start("ob_gzhandler"); after commenting it out I now only appear to get the rare out of memory error. However there is another error now, that I just can't find what is causing it. [30-Apr-2009 04:57:00] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/eliteace/public_html/realmbattles/attack.php:146) in /home/eliteace/public_html/realmbattles/attack.php on line 186 It is doing my head in looking through this over and over and any included files. here is the full attack.php script: <?php include "start.php"; player_session(); // grab current players stats from UserDetails $userrow = get_table($_SESSION['isLogined']); /* if (isset($_POST['co']) && !empty($_POST['co'])) { include "top.php"; $coid = $_POST['co']; if ($userrow['commander'] == $coid) { die("This person is already your commander!"); } if (is_numeric($coid) > 0) { $query = mysql_query("UPDATE `UserDetails` SET `commander`='" . $coid . "' WHERE `ID`='" . $_SESSION['isLogined'] . "'") or die("Could not set Commander!"); die("Commander Set!"); } else { die("Can only be a number!"); } include "bottom.php"; } */ // check you are not attacking yourself, or someone you shouldn't be attacking if ($cgi['defender_id2'] || $cgi['defender_id']) { if (($cgi['defender_id2'] == $_SESSION['isLogined']) || ($cgi['defender_id'] == $_SESSION['isLogined'])) { $strErr = " You can not attack or spy yourself. "; $cgi['id'] = ($cgi['defender_id2']) ? $cgi['defender_id2'] : $cgi['defender_id']; $cgi['defender_id2'] = ''; $cgi['defender_id'] = ''; } } // start the attacking process if ($cgi['defender_id2']) { $cgi['id'] = $cgi['defender_id2']; if ($cgi['attacks']) { //--------------------------Attacking // if your on protection cancel the attack if ($userrow['protection'] > 0) { include "top.php"; die("You can not attack someone while you are Protected!"); } // get attackers info $atacker = getUserDetails($_SESSION['isLogined']); // run pre-attacking checks if ($cgi['attacks'] > 15) { include("top.php"); die("Can not use more then 15 turns!"); } elseif ($cgi['attacks'] < 1) { include("top.php"); die("Positive Numbers only!"); } if($atacker->trainedAttackSold < "1"){ include("top.php"); die("You must have atleast one attack soldier to attack somebody!"); } if ($atacker->attackTurns >= $cgi['attacks']) { // get defenders info $defender = getUserDetails($cgi['id']); if ($atacker->commander == $cgi['id']) { include "top.php"; die("You can not attack your commander!"); } // if your opponent is on protection cancel the attack if ($defender->protection > 0) { include "top.php"; die("You can not attack someone while they are Protected!"); } // if your opponent is your officer stop the attack if ($defender->commander == $atacker->ID) { include "top.php"; die("You cannot attack your officers!"); } if ($defender->Alliance == $atacker->Alliance && $atacker->Alliance > 0) { include "top.php"; die("You cannot attack your fellow Alliance members"); } // $atackStrength = getStrikeAction($atacker); $atackStrength = getStrike($atacker->ID); // $atackStrength = rand(round($atackStrength / 2), $atackStrength); $atackStrength = round((rand(75, 100) * $atackStrength) / 100); $atackStrength = round(($atackStrength / 15) * $cgi['attacks']); if ($conf["race"][$atacker->race]["attack"]) { $atackStrength_inc = ((10 * $atackStrength) / 100); $atackStrength = $atackStrength + $atackStrength_inc; } $atackStrength = (($atacker->morale * $atackStrength) / 100); // $defStrength = getDefenseAction($defender); $defStrength = getDefence($defender->ID); // $defStrength = rand(round($defStrength / 2), $defStrength); $defStrength = round((rand(75, 100) * $defStrength) / 100); if ($conf["race"][$defender->race]["defense"]) { $defStrength_inc = ((10 * $defStrength) / 100); $defStrength = $defStrength + $defStrength_inc; } $defStrength = (($defender->morale * $defStrength) / 100); // choose a phrase $phrase = $conf["phrase"][rand(0, count($conf["phrase"]) - 1)]; $min_gold = $cgi['attacks'] * 5; $max_gold = $cgi['attacks'] * (20/3); if ($atackStrength > $defStrength) { $tgold = floor(rand($min_gold, $max_gold) * $defender->gold / 100); $alliance_taxed = "0"; $gold = $tgold; // if($userrow['in_alliance'] > "0") // { // $alliance_sql = "SELECT * FROM Alliance WHERE Alliance_ID = '$in_alliance' LIMIT 1"; // $alliance_query = mysql_query($alliance_sql); // $alliance_info = mysql_fetch_assoc($alliance_query); // $my_alliance_tax = $alliance_info['Alliance_Tax']; // $tax = 1-($my_alliance_tax/100); // $tax2 = $my_alliance_tax/100; // $alliance_taxed = floor($tgold * $tax2); // $gold = ceil($tgold * $tax); // } } else { $gold = 0; } $atackTrained = $atacker->trainedAttackSold + $atacker->trainedAttackMerc; $atackUnTrained = $atacker->untrainedMerc; $defTrained = $defender->trainedDefSold + $defender->trainedDefMerc; $defUnTrained = $defender->untrainedMerc; if($atackStrength > $defStrength) { $percent_at = 3; $div_at = 4; } else { $percent_at = 5; $div_at = 0; } if($atackStrength < $defStrength) { $percent_def = 3; $div_def = 4; } else { $percent_def = 5; $div_def = 0; } $atackUsersKilledAS = getKilled(((($atacker->trainedAttackSold/100)*$percent_at)/$div_at)); $atackUsersKilledAM = getKilled(((($atacker->trainedAttackMerc/100)*$percent_at)/$div_at)); $atackUsersKilledUM = getKilled(((($atacker->untrainedMerc/100)*$percent_at)/$div_at)); $atackUsersKilled = $atackUsersKilledAS + $atackUsersKilledAM + $atackUsersKilledUM; $defUsersKilledDS = getKilled(((($defender->trainedDefSold/100)*$percent_def)/$div_def)); $defUsersKilledDM = getKilled(((($defender->trainedDefMerc/100)*$percent_def)/$div_def)); $defUsersKilledUM = getKilled(((($defender->untrainedMerc/100)*$percent_def)/$div_def)); $defUsersKilled = $defUsersKilledAS + $defUsersKilledAM + $defUsersKilledUM; $aW = getUserWeapon($atacker); $atackWeaponsA = getWeaponStrA($atacker, $aW, 1, $cgi['attacks']); $atackWeapons = $atackWeaponsA[0]; $atackWeaponWas = $atackWeaponsA[1]; $atackWeaponIs = $atackWeaponsA[2]; $atackWeaponCount = $atackWeaponsA[3]; $aW = getDefUserWeapon($defender); $defWeaponsA = getWeaponStrA($defender, $aW, 0, $cgi['attacks']); $defWeapons = $defWeaponsA[0]; $defWeaponWas = $defWeaponsA[1]; $defWeaponIs = $defWeaponsA[2]; $defWeaponCount = $defWeaponsA[3]; $time = time(); $row = get_table($cgi['id']); if($row['active'] == 1) { updateUser($_SESSION['isLogined'], "attackTurns=attackTurns - {$cgi['attacks']} , gold=gold+$gold, trainedAttackSold=trainedAttackSold-$atackUsersKilledAS ,trainedAttackMerc =trainedAttackMerc- $atackUsersKilledAM,untrainedMerc=untrainedMerc-$atackUsersKilledUM "); updateUser($cgi['id'], " gold=gold-$gold, trainedDefSold=trainedDefSold-$defUsersKilledDS ,trainedDefMerc =trainedDefMerc- $defUsersKilledDM,untrainedMerc=untrainedMerc-$defUsersKilledUM "); $values = "'{$cgi['attacks']}','$atackStrength', '$defStrength','$tgold', '$gold', '$phrase','$atackUsersKilled','$defUsersKilled','$atackTrained','$atackUnTrained','$defTrained','$defUnTrained','$atackWeapons','$defWeapons','$atackWeaponWas','$atackWeaponIs','$atackWeaponCount', '$defWeaponWas', '$defWeaponIs', '$defWeaponCount', '$time','$alliance_taxed'"; } else { $phrase = $conf["phrase1"][rand(0, count($conf["phrase1"]) - 1)]; $values = "'{$cgi['attacks']}','$atackStrength', '$defStrength','$tgold', '$gold', '$phrase','$atackUsersKilled','$defUsersKilled','$atackTrained','$atackUnTrained','$defTrained','$defUnTrained','$atackWeapons','$defWeapons','$atackWeaponWas','$atackWeaponIs','$atackWeaponCount', '$defWeaponWas', '$defWeaponIs', '$defWeaponCount', '$time','$alliance_taxed'"; } $fields = "atackTurns ,atackStrength, defStrength,tgold, gold, phrase,atackUsersKilled,defUsersKilled,atackTrained,atackUnTrained,defTrained,defUnTrained,atackWeapons,defWeapons,atackWeaponWas,atackWeaponIs,atackWeaponCount, defWeaponWas, defWeaponIs, defWeaponCount,time,alliance_taxed"; addAtack($_SESSION['isLogined'], $cgi['id'], $fields, $values); $atak = getAtackByUser1User2AndTime($_SESSION['isLogined'], $cgi['id'], $time, " ID "); updateAllActions($_SESSION['isLogined'],$atacker); updateAllActions($cgi['id'],$defender); header("Location: battlelog.php?id={$atak->ID}"); } else { $strErr = "You do not have enough turns."; } } // end attacking process // start the spying process } elseif ($cgi['defender_id']) { $cgi['id'] = $cgi['defender_id']; $atacker = getUserDetails($_SESSION['isLogined']); if ($cgi['numspies'] == "") { include("top.php"); die("Please enter a number of spies to send!"); } if ($cgi['numspies'] < 0) { include("top.php"); die("Positive Numbers only!"); } if ($atacker->commander == $cgi['id']) { include "top.php"; die("You can not spy your commander!"); } // if your protected cancel spy if ($userrow['protection'] > 0) { include("top.php"); die("You can not spy someone when you are Protected!"); } if ($cgi['numspies'] > $atacker->spies) $cgi['numspies'] = $atacker->spies; // get the other users info $defender = getUserDetails($cgi['id']); // If you dont have any spies stop the spy if($atacker->spies < "1"){ include("top.php"); die("You can not spy with no spies!"); } // if your opponent is protected cancel spy if ($defender->protection > 0) { include("top.php"); die("You can not spy someone when they are Protected!"); } // if your opponent is your officer stop the spy if ($defender->commander == $atacker->ID) { include "top.php"; die("You can not spy your officers!"); } $time = time(); //echo ($atacker->currentSpySkill+1).";;".$defender->currentSpySkill."##<br>"; //if (($atacker->currentSpySkill+1)<$defender->currentSpySkill){ $tSpies = $atacker->spies; $atacker->spies = $atacker->spies - $cgi['numspies']; // $spyStrength = getCovertAction($atacker->ID); $spyStrength = getCovert($atacker->ID); $atacker->spies = $tSpies; // $spyDefStrength = getCovertAction($defender->ID); $spyDefStrength = getCovert($defender->ID); // attackers army morale $spyStrength = (($atacker->morale * $spyStrength) / 100); // defenders army morale $spyDefStrength = (($defender->morale * $spyDefStrength) / 100); if ($spyStrength < ($spyDefStrength - 100)) { $isSuccess = 0; $fields = " `time` , `spies`, `isSuccess`"; $values = "'$time' , '" . $cgi['numspies'] . "', '$isSuccess'"; $spieslost = ((20 * $cgi['numspies']) / 100); updateUser($atacker->ID, " spies=spies-$spieslost "); } else { $isSuccess = 1; $spies = $cgi['numspies']; $race = $defender->race; //$atacker->spies=$cgi['numspies']; $dif = $spyStrength - $spyDefStrength; if ($dif > 100) $dif = 100; $dif += 100; $difPerc = $dif / 2; // echo "--$difPerc--<br>"; $trainedAttackSold = spiedValue($defender->trainedAttackSold, $difPerc); $trainedAttackMerc = spiedValue($defender->trainedAttackMerc, $difPerc); $trainedDefSold = spiedValue($defender->trainedDefSold, $difPerc); $trainedDefMerc = spiedValue($defender->trainedDefMerc, $difPerc); $untrainedMerc = spiedValue($defender->untrainedMerc, $difPerc); $untrainedSold = spiedValue($defender->untrainedSold, $difPerc); $miners = spiedValue($defender->miners, $difPerc); $strikeAction = getStrikeAction($defender); $strikeAction = spiedValue($strikeAction, $difPerc); $defenceAction = getDefenseAction($defender); $defenceAction = spiedValue($defenceAction, $difPerc); $covertSkill = spiedValue($defender->currentSpySkill, $difPerc); $covertOperatives = spiedValue($defender->spies, $difPerc); $siegeLevel = spiedValue($defender->siegeLevel, $difPerc); $atackTurns = spiedValue($defender->attackTurns, $difPerc); $unitProduction = spiedValue($defender->currentUnitProduction, $difPerc); /* $weapons $types $quantities $strengths $allStrengths */ $weapon1 = getUserAllWeapon($defender); for ($i = 0; $i < count($weapon1); $i++) { if (!spiedValue(0, $difPerc)) { $weapons .= spiedValue($weapon1[$i]->weaponID, $difPerc) . ";"; $types .= spiedValue($weapon1[$i]->isAtack, $difPerc) . ";"; $types2 .= $weapon1[$i]->isAtack . ";"; $quantities .= spiedValue($weapon1[$i]->weaponCount, $difPerc) . ";"; $strengths .= spiedValue($weapon1[$i]->weaponStrength, $difPerc) . ";"; //$allStrengths.=spiedValue($weapon1[$i]->weaponID,$difPerc).";"; if ($weapon1[$i]->isAtack) { $tS = $conf["race"][$defender->race]["weapon"][$weapon1[$i]->weaponID]["strength"]; } else { $tS = $conf["race"][$defender->race]["defenseweapon"][$weapon1[$i]->weaponID]["strength"]; } $allStrengths .= spiedValue($tS, $difPerc) . ";"; } } if (strlen($weapons)) { $weapons = substr($weapons, 0, strlen($weapons) - 1); $types = substr($types, 0, strlen($types) - 1); $types2 = substr($types2, 0, strlen($types2) - 1); $quantities = substr($quantities, 0, strlen($quantities) - 1); $strengths = substr($strengths, 0, strlen($strengths) - 1); $allStrengths = substr($allStrengths, 0, strlen($allStrengths) - 1); } $trainedAttackSold = $defender->trainedAttackSold; $fields = "`spyStrength`, `spyDefStrength`, `trainedAttackSold`, `trainedAttackMerc`, `trainedDefSold`, `trainedDefMerc`, `untrainedMerc`, `untrainedSold`, `strikeAction` , `defenceAction`, `covertSkill` , `covertOperatives`, `siegeLevel` , `atackTurns` , `unitProduction` , `weapons`, `types`, `types2` , `quantities`, `strengths` , `allStrengths`, `time` , `spies`, `isSuccess`, `race`, `miners`"; $values = "'$spyStrength', '$spyDefStrength', '$trainedAttackSold', '$trainedAttackMerc', '$trainedDefSold', '$trainedDefMerc', '$untrainedMerc', '$untrainedSold', '$strikeAction', '$defenceAction', '$covertSkill', '$covertOperatives', '$siegeLevel' , '$atackTurns' , '$unitProduction' , '$weapons', '$types', '$types2' , '$quantities', '$strengths' ,'$allStrengths', '$time' , '$spies', '$isSuccess', '$race', '$miners'"; } //echo $fields."<br>"; //echo $values; //return; addSpy($atacker->ID, $defender->ID, $fields, $values); //return; $spy = getSpyByUser1User2AndTime($atacker->ID, $defender->ID, $time, " ID "); updateAllActions($_SESSION['isLogined'],$atacker); updateAllActions($cgi['id'],$defender); header("Location: spylog.php?id={$spy->ID}"); } // end spying process include "top.php"; ?> <head> <SCRIPT language="JavaScript"> <!-- function go_there() { var where_to= confirm("Attacking this user will still give weapon damage. \n Are you sure you want to do it?"); if (where_to== true) { document.attack.submit(); } } //--> </SCRIPT> </head> <TD style="PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-TOP: 12px" vAlign=top align=left> <BR> <center> <FONT color=red><?php $enemy = getUserDetails($cgi['id']); echo $strErr; if($enemy->active == 2) { echo "Even though you dont use Attack Turns to attack a banned player, and dont earn any copper, weapon damage still occurs, and you will recieve nothing if your weapons get damaged"; } ?></FONT></center> <P> <TABLE width="100%"> <TBODY> <TR> <TD style="PADDING-RIGHT: 25px" vAlign=top width="50%"> <FORM name=attack action=attack.php method=post> <TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH align=middle colSpan=2>Attack Mission</TH></TR> <TR> <TD>Target:</TD> <TD><?=$enemy->userName?></TD></TR> <TR> <TD>Attack turns to use?</TD> <?php if ($userrow['aat'] == "0") { echo "<TD><INPUT size=3 name=attacks> / 15</TD></TR>"; } else { if ($userrow['aat'] > $userrow['attackTurns']) { $default = $userrow['attackTurns']; } else { $default = $userrow['aat']; } echo "<TD><INPUT size=3 name=attacks value=" . $default . "> / 15</TD></TR>"; } ?> <TR> <TD align=middle colSpan=2> <?php if ($enemy->protection > 0) { echo "<INPUT type=submit value=\"Protected\" name=attackbut DISABLED></TD></TR></TBODY></TABLE>"; } elseif ($enemy->Alliance == $userrow['Alliance'] && $userrow['Alliance'] != "" && $userrow['Alliance'] != "0") { echo "<INPUT type=submit value=\"Alliance\" name=attackbut DISABLED></TD></TR></TBODY></TABLE>"; }elseif($enemy->active == 2){ echo "<INPUT type=button value=\"Attack\" name=attackbut onclick=\"document.attack.attackbut.value='Attacking..'; document.attack.attackbut.disabled=true; go_there();\"></TD></TR></TBODY></TABLE>"; } else { echo "<INPUT onclick=\"document.attack.attackbut.value='Attacking..'; document.attack.attackbut.disabled=true; document.attack.submit();\" type=submit value=\"Attack!\" name=attackbut></TD></TR></TBODY></TABLE>"; } ?> <input type=hidden value=<?=$cgi['id']?> name=defender_id2> <INPUT type=hidden value=93aa2b6a02603399396203313b45827e name=hash> </FORM><BR><A name=spy></A> <FORM name=spyr action=attack.php method=post><INPUT type=hidden value=recon name=mission_type> <TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH colSpan=2>Reconaissance Mission</TH></TR> <TR> <TD>Number of spies to send</TD> <TD><INPUT size=3 name=numspies></TD></TR> <TR> <TD align=middle colSpan=2> <?php if ($enemy->protection > 0) { echo "<INPUT type=submit value=\"Protected\" name=spyrbut DISABLED></TD></TR></TBODY></TABLE>"; } elseif ($enemy->Alliance == $userrow['Alliance'] && $userrow['Alliance'] != "" && $userrow['Alliance'] != "0") { echo "<INPUT type=submit value=\"Alliance\" name=attackbut DISABLED></TD></TR></TBODY></TABLE>"; } else { echo "<INPUT onclick=\"document.spyr.spyrbut.value='Spying..'; document.spyr.spyrbut.disabled=true; document.spyr.submit();\" type=submit value=\"Send Spies\" name=spyrbut></TD></TR></TBODY></TABLE>"; } ?> <INPUT type=hidden value=<?=$cgi['id']?> name=defender_id> <INPUT type=hidden value=93aa2b6a02603399396203313b45827e name=hash> </FORM></TD> <TD vAlign=top> <TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH colSpan=2>Personnel</TH> </TR> <TR> <TD><B>Miners</B></TD> <TD align=right> <?php numecho($user->miners) ?> </TD> </TR> <TR> <TD><B>Trained Attack Soldiers</B></TD> <TD align=right> <?php numecho($user->trainedAttackSold) ?> </TD> </TR> <TR> <TD><B>Trained Attack Mercenaries</B></TD> <TD align=right> <?php numecho($user->trainedAttackMerc) ?> </TD> </TR> <TR> <TD><B>Trained Defense Soldiers</B></TD> <TD align=right> <?php numecho($user->trainedDefSold) ?> </TD> </TR> <TR> <TD><B>Trained Defense Mercenaries</B></TD> <TD align=right> <?php numecho($user->trainedDefMerc) ?> </TD> </TR> <TR> <TD><B>Untrained Soldiers</B></TD> <TD align=right> <?php numecho($user->untrainedSold) ?> </TD> </TR> <TR> <TD><B>Untrained Mercenaries</B></TD> <TD align=right> <?php numecho($user->untrainedMerc) ?> </TD> </TR> <TR> <TD class=subh><B>Spies</B></TD> <TD class=subh align=right> <?php numecho($user->spies) ?> </TD> </TR> <TR> <TD><B>Total Fighting Force</B></TD> <TD align=right> <?php numecho(getTotalFightingForce($user->ID)) ?> </TD> </TR> </TBODY> </TABLE> <BR> <TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%" border=0> <TBODY> <TR> <TH colSpan=3>Military Effectiveness</TH> </TR> <TR> <TD><B>Strike Action</B></TD> <TD align=right> <?php numecho(getStrikeAction($user)) ?> </TD> <TD align=right>Ranked <?php if ($userR->strikeActionRank) { numecho($userR->strikeActionRank); } else echo "#unranked"; ?> </TD> </TR> <TR> <TD><B>Defensive Action</B></TD> <TD align=right> <?php numecho(getDefenseAction($user)); ?> </TD> <TD align=right>Ranked <?php if ($userR->defenceActionRank) { numecho($userR->defenceActionRank); } else echo "#unranked"; ?> </TD> </TR> <TR> <TD><B>Covert Action</B></TD> <TD align=right> <?php numecho(getCovertAction($user)) ?> </td> <td align="right">Ranked <?php if ($userR->covertActionRank) { numecho($userR->covertActionRank); } else echo "#unranked"; ?> </td> </tr> </tbody> </table></td></tr></tbody></table> <?php include("bottom.php"); ?> please note this script has a looooonggggggggg wayyyy to go. any help is appreciated like always. Cheers, ACE Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 1, 2009 Author Share Posted May 1, 2009 bump Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 1, 2009 Share Posted May 1, 2009 The line where the output is occurring is a user written function. That function is causing some output, either an error message or it is deliberately outputting something. You cannot have any output before a header(). Quote Link to comment Share on other sites More sharing options...
deth4uall Posted May 1, 2009 Share Posted May 1, 2009 I have had a problem similar to this before... put <?php exit; ?> after the headers, this will stop the other parts of the displaying info from loading when you declare a header... Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 1, 2009 Author Share Posted May 1, 2009 adding exit; after header's and changing the variables that are divided by zero to one seems to have fixed attack.php And there is no Out of memory error's showing up in the error log for today. I shall post back here if the problem arises again. Thank you everyone for your assistance and patience. Regards, ACE Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 2, 2009 Author Share Posted May 2, 2009 ah the blasted things back to haunt me. [01-May-2009 21:17:08] PHP Fatal error: Out of memory (allocated 44564480) (tried to allocate 2097152 bytes) in /home/eliteace/public_html/realmbattles/vsys.php on line 379 I haven't changed anything in that file for 150 lines either side of line 379. Would a increase in players contribute to this problem? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 4, 2009 Author Share Posted May 4, 2009 A new update. in the error log I am getting 4 of these in a row... [04-May-2009 03:34:27] PHP Fatal error: Out of memory (allocated 45350912) (tried to allocate 35 bytes) in /home/eliteace/public_html/realmbattles/vsys.php on line 379 and then several of these are coming up after it... [04-May-2009 07:19:15] PHP Warning: array_rand() [<a href='function.array-rand'>function.array-rand</a>]: First argument has to be an array in /home/eliteace/public_html/ads/ads.php on line 36 although the time difference is of a fair size. Is it possible that the problems are linked? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 5, 2009 Author Share Posted May 5, 2009 it was constantly line 379. But there has been very rarely these lines... [02-May-2009 20:14:15] PHP Fatal error: Out of memory (allocated 45350912) (tried to allocate 35 bytes) in /home/eliteace/public_html/realmbattles/vsys.php on line 2177 line 398 has been coming up more and more over the last day. [04-May-2009 22:07:22] PHP Fatal error: Out of memory (allocated 45088768) (tried to allocate 35 bytes) in /home/eliteace/public_html/realmbattles/vsys.php on line 398 Quote Link to comment Share on other sites More sharing options...
premiso Posted May 5, 2009 Share Posted May 5, 2009 What exactly does this script do? It seems like it goes into an infinite loop sometimes or loops that take too long and eat up memory. Does it deal with images at all? How about creating complex arrays, or uses a bunch of loops that are done dynamically....We do not have the insight to really help you out with this error. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 5, 2009 Author Share Posted May 5, 2009 function getWeaponArray1($Weapons,$WeaponCount ){ $weaponAW=split(";",$Weapons); $weaponAWC=split(";",$WeaponCount); $k=0; for ($i=0;$i<count($weaponAW);$i++){ for ($j=0; $j<$weaponAWC[$i] ;$j++){ // line 2177 $weaponA[$k]=$weaponAW[$i]; $k++; } } return $weaponA; } function getStrikeAction($user) { global $conf; $num = 0; $trainedCount = $user->trainedAttackSold + $user->trainedAttackMerc; $untrainedCount = $user->untrainedMerc + $user->untrainedSold; $weaponA1 = getUserWeapon($user); if (!count($weaponA1) && !$trainedCount) return 0; $k=0; for ($i=0;$i<count($weaponA1);$i++){ for ($j=0; $j<$weaponA1[$i]->weaponCount ;$j++){ // line 398 $weaponA[$k]=$weaponA1[$i]; $k++; } } neither function has been altered since it was first written over a year ago, and the problems only recently started occuring. Quote Link to comment Share on other sites More sharing options...
premiso Posted May 6, 2009 Share Posted May 6, 2009 So it is a loop causing issues. I would test those loops and make sure that they are as efficient as they can be. Add some debugging in there so you can see how many times the loop actually runs etc and what type of content is being pulled out. As that is your issue. Quote Link to comment 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.