Xyphon Posted November 24, 2008 Share Posted November 24, 2008 I was creating a battle script.. And well, it displays nothing for some reason.. Get ready, heres my over 800 line script to get you guys to find out what is wrong.... <?PHP include('Connect.php'); include('top.php'); include('pokeinfo.php'); if (!isset($_COOKIE['UserID'])) { $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); echo "Sorry, you are not logged in. <a href='Login.php'>Login now</a>"; include('bottom.php'); exit; } mysql_query("UPDATE Battle_Information SET Battle = 'True' WHERE ID = '$ID'"); $BI_Enemy_Attack="20"; $BI_Enemy_Special_Attack="20"; $BI_Enemy_Defense="20"; $BI_Enemy_Special_Defense="20"; function Battle_Unset() { mysql_query("UPDATE Battle_Information SET Battle = 'False' WHERE ID = '$ID'"); } $Result887 = mysql_query("SELECT * FROM Battle_Information"); $Rows887 = mysql_fetch_array($Result887); $Battle = $Rows887['Battle']; if($Battle != "True") { echo "Sorry you are not in a battle."; } else { //Check for errors //If HP is 0 if($P_MHP1=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; if($P_NEXP1=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; //Enemy Errors //If HP is 0 if($E_MHP=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; if($E_NEXP=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; //Define Dead Variables $B_Dead= 0; //Find Dead Values if($P_HP1== 0 || $P_Name1=="None") { $B_Dead= round($B_Dead + 1); } { //If All Pokémon Have Fainted if($B_Dead=="1") { echo "You have lost.. <html> <FORM method='GET' action='index.php' target='_blank'> <input type='submit' name='Lost' value='Continue'> </html>"; Battle_Unset(); } } include('bottom.php'); exit; $B_Result3= mysql_query("SELECT * FROM pokemon_info WHERE pokemon_name='$P_Name1' LIMIT 1"); $B_Rows3= mysql_fetch_array($B_Result3); //If Rows Are Empty if(empty($B_Rows3)) { //Display Message echo "Sorry there is an error."; } Battle_Unset(); include('bottom.php'); exit; //Find Rows $B_Result10= mysql_query("SELECT * FROM Battle_Information"); $B_Rows10= mysql_fetch_array($B_Result10); $E_ID = $B_Rows10['BI_Enemy_ID']; $E_Name = $B_Rows10['BI_Enemy_Name']; $EP = $B_Rows10['BI_Enemy_Pokemon']; $EP_Attack1 = $B_Rows10['BI_Enemy_Pokemon_Attack1']; $EP_Attack2 = $B_Rows10['BI_Enemy_Pokemon_Attack2']; $EP_Attack3 = $B_Rows10['BI_Enemy_Pokemon_Attack3']; $EP_Attack4 = $B_Rows10['BI_Enemy_Pokemon_Attack4']; $EP_Name = $B_Rows10['BI_Enemy_Pokemon_Name']; $EP_Attack = $B_Rows10['BI_Enemy_Pokemon_Attack']; $EP_Defense = $B_Rows10['BI_Enemy_Pokemon_Defense']; $EP_HP = $B_Rows10['BI_Enemy_Pokemon_HP']; $EP_MHP = $B_Rows10['BI_Enemy_Pokemon_MHP']; $EP_IMG = $B_Rows10['BI_Enemy_Pokemon_IMG']; $EP_Gender = $B_Rows10['BI_Enemy_Pokemon_Gender']; $EP_Level = $B_Rows10['BI_Enemy_Pokemon_Level']; $EP_EXP = $B_Rows10['BI_Enemy_Pokemon_EXP']; $EP_NEXP = $B_Rows10['BI_Enemy_Pokemon_NEXP']; $EP_GenderS = $B_Rows10['BI_Enemy_Pokemon_Gender_Sign']; $EP_SATK = $B_Rows10['BI_Enemy_Pokemon_Special_Attack']; $EP_SDEF = $B_Rows10['BI_Enemy_Pokemon_Special_Defense']; $EP_Type = $B_Rows10['BI_Enemy_Pokemon_Type']; $EP_Type2 = $B_Rows10['BI_Enemy_Pokemon_Type2']; $B_Result4= mysql_query("SELECT * FROM pokemon_info WHERE pokemon_name='$EP_Name' LIMIT 1"); $B_Rows4= mysql_fetch_array($B_Result4); //If Rows Are Empty if(empty($B_Rows4)) { //Display Message echo "There is an error."; Battle_Unset(); include('bottom.php'); exit; } //Define New Variables $B_Success="You have not performed an action as of yet. Please choose an action above."; //Display Form echo "<form action='battle.php' method='POST' name='BPOST'> <input type='hidden' name='B_Submit' value='1'> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav_header' align='center' width='100%'>"; //Display Content echo "$UserName's $P_Name1 Versus $E_Name's $CB_PName"; //Continue Form echo "</td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='50%'> <b>$P_Name1</b> </td> <td class='tnav' align='center' width='50%'> <b>$EP_Name</b> </td> </tr><tr> <td class='tnav' align='center' width='50%'> Level $P_Level1 (EXP: $P_EXP1/$P_NEXP1) </td> <td class='tnav' align='center' width='50%'> Level $EP_Level (EXP: $EP_EXP/$EP_NEXP) </td> </tr><tr> <td class='tnav' align='center' width='50%'> <div class='bar' align='left' width='50px'><img src='/EXP_Bar1.png' style='height: 7px; width: $B_EXPPercentage1%' title='EXP: $P_EXP1/$P_NEXP1 ($B_EXPPercentage1%)' alt=''></div> </td> <td class='tnav' align='center' width='50%'> <div class='bar' align='left' width='50px'><img src='/EXP_Bar1.png' style='height: 7px; width: $B_EXPPercentage2%' title='EXP: $EP_EXP/$EP_NEXP ($B_EXPPercentage2%)' alt=''></div> </td> </tr><tr> <td class='tnav' align='center' width='50%'> <img src='$P_Image1' title='$P_Name1' alt='$P_Name1'> </td> <td class='tnav' align='center' width='50%'> <img src='$EP_IMG' title='$EP_Name' alt='$EP_Name'> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='25%'> <b>HP: $P_HP1/$P_MHP1</b> </td> <td class='tnav' align='center' width='25%'> <b>HP: $EP_PHP/$EP_MHP</b> </td> </tr><tr> <td class='tnav' align='center' width='25%'> <div class='bar' align='left' width='25px'><img src='/HP_Bar1.png' style='height: 11px; width: $B_HPPercentage1%' title='HP: $P_HP1/$P_MHP1 ($B_HPPercentage1%)' alt='HP: $P_HP1/$P_MHP1 ($B_HPPercentage1%)'></div> </td> <td class='tnav' align='center' width='25%'> <div class='bar' align='left' width='25px'><img src='/HP_Bar1.png' style='height: 11px; width: $B_HPPercentage2%' title='HP: $CB_PHP/$CB_PMHP ($B_HPPercentage2%)' alt='HP: $CB_PHP/$CB_PMHP ($B_HPPercentage2%)'></div> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='25%'> <b>Attacks</b> </td> <td class='tnav' align='center' width='25%'> <b>Change Party</b> </td> <td class='tnav' align='center' width='25%'> <b>Item</b> </td> <td class='tnav' align='center' width='25%'> <b>Escape</b> </td> </tr><tr> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Attack' checked onclick=\"B_Form$Name.B_Item.disabled= false; B_Form$Name.B_Attack.disabled= false; B_Form$Name.B_Switch.disabled= true;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Change Party' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= false;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Item' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= true;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Escape' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= true;\"> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='50%'> <b>Your Inventory</b> </td> <td class='tnav' align='center' width='50%'> <b>$P_Name1's Attacks</b> </td> </tr><tr> //Continue Form <td class='tnav' align='center' width='50%'> <select name='B_Attack'>"; //If Session Is Set if(isset($_SESSION['B_PreviousMove'])) { //Define Session Variables $B_PreviousMove= $_SESSION['B_PreviousMove']; //If Previous Move Is Invalid if($B_PreviousMove < 1 || $B_PreviousMove > 5) { //Define New Variables $B_PreviousMove= 1; } //Display Information echo "<option value='$B_PreviousMove'>Previous Move</option>"; } //Continue Form echo "<option value='1'>$P_Move1_1 </option> <option value='2'>$P_Move2_1 </option> <option value='3'>$P_Move3_1 </option> <option value='4'>$P_Move4_1 </option> </select> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='100%'> <b>Current Turn</b> </td> </tr><tr> <td class='tnav' align='center' width='100%'> $B_Success </td> </tr><tr> <td class='tnav' align='center' width='100%'> <b>Change Party</b> </td> </tr><tr> <td class='tnav' align='center' width='100%'> <select name='B_Switch' disabled> <option value='0' onclick=\"B_Form$Name.B_Action[0].disabled= false; B_Form$Name.B_Action[1].disabled= false; B_Form$Name.B_Action[3].disabled= false;\">Don't Change Party</option> <option value='2' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name2 (LV: $P_Level2; HP: $P_HP2/$P_MHP2; MP: $P_MP2/$P_MMP2)</option> <option value='3' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name3 (LV: $P_Level3; HP: $P_HP3/$P_MHP3; MP: $P_MP3/$P_MMP3)</option> <option value='4' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name4 (LV: $P_Level4; HP: $P_HP4/$P_MHP4; MP: $P_MP4/$P_MMP4)</option> <option value='5' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name5 (LV: $P_Level5; HP: $P_HP5/$P_MHP5; MP: $P_MP5/$P_MMP5)</option> <option value='6' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name6 (LV: $P_Level6; HP: $P_HP6/$P_MHP6; MP: $P_MP6/$P_MMP6)</option> </select> </td> </tr><tr> <td class='tnav' align='center' width='100%'> <input type='submit' name='B_Submit2$Name' value='Continue$Dots' class='inputform' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"> </td> </tr></table>"; $B_Submit= $_POST['B_Submit']; $B_Action= $_POST['B_Action']; $B_Item= $_POST['B_Item']; $B_Attack= $_POST['B_Attack']; $B_Switch= $_POST['B_Switch']; $B_Action= mysql_real_escape_string($B_Action); $B_Item= mysql_real_escape_string($B_Item); $B_Attack= mysql_real_escape_string($B_Attack); $B_Switch= mysql_real_escape_string($B_Switch); //If Action Is Escape if($B_Action=="Escape") { //Define Sessions Define_Session("B_Submit", "True"); Define_Session("B_Success", "You have successfully escaped the enemy.<br /><br /><a href='index.php'>[ RPG Homepage ]</a><br /><a href='story_mode.php'>[ Story Mode ]</a><br /><a href='battle_a_trainer.php'>[ Battle A Trainer ]</a><br /><a href='pokemon_maps.php'>[ Pokémon Maps ]</a><br /><a href='pokemon_center.php'>[ Pokémon Center ]</a>"); Define_Session("B_Status", "Escaped"); //Redirect User header("location: battle.php"); //Exit Page exit; } //If HP Exceeds Maximum HP if($P_HP1 > $P_MHP1) { //Define New Variables $P_HP1= $P_MHP1; } //If MP Exceeds Maximum MP if($P_MP1 > $P_MMP1) { //Define New Variables $P_MP1= $P_MMP1; } //If Action Is Change Party elseif($B_Action=="Change Party") { //If Specified Slot Is Not Valid if($B_Switch < 2 || $B_Switch > 6) { echo "The slot is invalid"; //Redirect User header("location: battle.php"); //Exit Page exit; } //Find Rows $B_Result8= mysql_query("SELECT * FROM pokemon_info WHERE User_ID='$ID' AND pokemon_slot='$B_Switch' LIMIT 1"); $B_Rows8= mysql_fetch_array($B_Result8); //Define Pokémon Variables $PD_ID= $B_Rows8['pokemon_id']; $PD_Name= $B_Rows8['pokemon_name']; $PD_Sprite= $B_Rows8['pokemon_image']; //If Rows Are Empty if(empty($B_Rows8)) { echo "Sorry, the Pokemon seems to be unexistent."; //Redirect User header("location: battle.php"); //Exit Page exit; } //Update Pokémon Information mysql_query("UPDATE pokemon_info SET pokemon_slot='$B_Switch' WHERE User_ID='$ID' AND pokemon_slot='1' LIMIT 1"); //Update Pokémon Information mysql_query("UPDATE Pokémon SET pokemon_slot='1' WHERE User_ID='$ID' AND pokemon_id='$PD_ID' LIMIT 1"); echo "The pokemon have switched!"; //Destroy Sessions unset($_SESSION['B_PreviousMove']); //Redirect User header("location: battle.php"); //Exit Page exit; } else { //Declare B_BeginAttack Function function B_BeginAttack($BA_AttackEnemy) { //Define Globalized Variables global $ID; global $UserName; global $P_ID1; global $P_Name1; global $P_Name2; global $P_Name3; global $P_Name4; global $P_Name5; global $P_Name6; global $P_Image1; global $P_Level1; global $P_EXP1; global $P_NEXP1; global $P_HP1; global $P_HP2; global $P_HP3; global $P_HP4; global $P_HP5; global $P_HP6; global $P_MHP1; global $P_MP1; global $P_MMP1; global $P_ATK1; global $P_SATK1; global $P_DEF1; global $P_SDEF1; global $P_Type; global $P_Type21; global $P_Attack11; global $P_Attack21; global $P_Attack31; global $P_Attack41; global $E_ID; global $E_Type; global $E_Name; global $EP_ID; global $EP_Name; global $EP_IMG; global $EP_Level; global $EP_EXP; global $EP_NEXP; global $EP_HP; global $EP_MHP; global $EP_ATK; global $EP_DEF; global $EP_SATK; global $EP_SDEF; global $EP_Type; global $EP_Type2; global $EP_Gender; global $EP_GenderS; global $EP_Attack1; global $EP_Attack2; global $EP_Attack3; global $EP_Attack4; global $B_Item; global $B_Attack; global $B_Switch; //Define Random Variables $B_EnemysAttack= rand(1, 4); $Random_EXP= rand(round(($EP_Level / ), round(($EP_Level / 4))); $B_RandomMultiEXP= rand(2, 3); $B_DividedEXP= rand(3, 7); $B_HPIncrease= rand(2, 3); if($P_AD=="Attack") { $B_ATKIncrease= rand(3, 5); } else { $B_ATKIncrease= rand(2, 5); } if($P_AD=="Defense") { $B_DEFIncrease= rand(3, 5); } else { $B_DEFIncrease= rand(2, 5); } if($P_AD=="SpecialAttack") { $B_SATKIncrease= rand(3, 5); } else { $B_SATKIncrease= rand(2, 5); } if($P_AD=="SpecialDefense") { $B_SDEFIncrease= rand(3, 5); } else { $B_SDEFIncrease= rand(2, 5); } //If Attack Enemy Is True if($BA_AttackEnemy=="True") { //Define Sessions Define_Session("B_PreviousMove", $B_Attack); //If First Move Is Chosen if($B_Attack== 1) { //Define Move Variables $B_Move= $P_Attack11; } //If Second Move Is Chosen elseif($B_Attack== 2) { //Define Move Variables $B_Move= $P_Attack21; } //If Third Move Is Chosen elseif($B_Attack== 3) { //Define Move Variables $B_Move= $P_Attack31; } //If Fourth Move Is Chosen else { //Define Move Variables $B_Move= $P_Attack41; } //Find Rows $B_Result9= mysql_query("SELECT * FROM Move_Data WHERE MD_Name='$B_Move' LIMIT 1"); $B_Rows9= mysql_fetch_array($B_Result9); //Define Move Data Variables $MD_Name= $B_Rows9['MD_Name']; $MD_Type= $B_Rows9['MD_Type']; $MD_Power= $B_Rows9['Power']; $MD_Physical= $B_Rows9['Physical']; $MD_Special= $B_Rows9['Special']; //If Rows Are Empty if(empty($B_Rows9)) { //Define Sessions Define_Session("B_Submit", "True"); Define_Session("B_Success", "Sorry, the specified move does not appear to be existant; please report this."); //Redirect User header("location: battle.php"); //Exit Page exit; } if($MD_Physical=="Yes") { //Define Damage Variables $B_YourDamage= round(($MD_Power / 1) * ($P_ATK1 / 1) / ($EP_DEF / 1) / (5 / 1) + ($P_Level1)); //If Your Damage Is Invalid if($B_YourDamage < 0) { //Define New Variables $B_YourDamage= 0; } } else { //Define Damage Variables $B_YourDamage= round(($MD_Power / 1) * ($P_SATK1 / 1) / ($EP_SDEF / 1) / (5 / 1) + ($P_Level1)); //If Your Damage Is Invalid if($B_YourDamage < 0) { //Define New Variables $B_YourDamage= 0; } echo "You have done $B_YourDamage Damage"; $EP_HP= round($EP_HP - $B_YourDamage); } //If Enemy's HP Is Below Zero if($EP_HP < 0) { //Define New Variables $EP_HP= 0; } //If Enemy's HP Is Too High elseif($EP_HP > $EP_MHP) { //Define New Variables $EP_HP= $EP_MHP; } } //If Enemy Has Not Fainted if($EP_HP != 0) { //If First Move Is Chosen if($B_EnemysAttack== 1) { //Define Move Variables $B_EnemysMove= $EP_Attack1; } //If Second Move Is Chosen elseif($B_EnemysAttack== 2) { //Define Move Variables $B_EnemysMove= $EP_Attack2; } //If Third Move Is Chosen elseif($B_EnemysAttack== 3) { //Define Move Variables $B_EnemysMove= $EP_Attack3; } //If Fourth Move Is Chosen elseif($B_EnemysAttack== 4) { //Define Move Variables $B_EnemysMove= $EP_Attack4; } $B_Result10= mysql_query("SELECT * FROM Move_Data WHERE MD_Name='$B_EnemysMove' LIMIT 1"); $B_Rows10= mysql_fetch_array($B_Result10); //Define Move Data Variables $MD_EnemysName= $B_Rows10['MD_Name']; $MD_EnemysSpecial= $B_Rows10['MD_Special']; $MD_EnemysPhysical= $B_Rows10['MD_Physical']; $MD_EnemysPower= $B_Rows10['MD_Power']; $Dodge_Rand= rand(1, 5); $Counter_Rand= rand(1, 5); $B_Submit10= $_POST['B_Submit10']; $B_Submit11= $_POST['B_Submit11']; $B_Submit10= mysql_real_escape_string($B_Submit10); $B_Submit11= mysql_real_escape_string($B_Submit11); echo "The enemy is using $B_EnemysMove<br><FORM method='GET' action='battle.php' target='_blank'> <input type='submit' name='B_Submit10' value='Dodge'><br> <input type='submit' name='B_Submit11' value='Counter'>"; if(isset($B_Submit10)) { if($Dodge_Rand=="5") { echo "You have successfully dodged the attack!"; } else { //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_ATK / 1) / ($P_DEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); } } else { if($Counter_Rand=="5") { echo "You have pulled off a counter attack you have done $B_YourDamage Damage"; //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_ATK / 1) / ($P_DEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } }echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); } else { //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) + ($EP_ATK / 1) - ($P_DEF1 / 1)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } }echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); //If Your HP Is Below Zero if($P_HP1 < 0) { //Define New Variables $P_HP1= 0; } //If Your HP Is Too High elseif($P_HP1 > $P_MHP1) { //Define New Variables $P_HP1= $P_MHP1; } } //If Enemy Has Fainted if($EP_HP== 0) { //Define Random Variables $B_GainedCredits= rand(100, 400); //Define New Variables $U_DiamondCredits= round($U_DiamondCredits + $B_GainedCredits); //Define Formatted Variables $B_DisplayGainedCredits=="$B_GainedCredits"; //Define EXP Variables $B_GainedEXP= round(($EP_HP) * ($EP_Level) / (15 / 1)); //Define New Variables $P_EXP1= round($P_EXP1 + $B_GainedEXP); //Define Sentence Variables $B_EXPSentence1="<br />Your $P_Name1 has gained <b>$B_GainedEXP</b> Experience Point(s)!"; //If Your EXP Is Below Zero if($P_EXP1 < 0) { //Define New Variables $P_EXP1= 0; } //If Your EXP Is Too High elseif($P_EXP1 >= $P_NEXP1) { //Define New Variables $P_Level1= round($P_Level1 + 1); $P_EXP1= round($P_EXP1 - $P_NEXP1); $B_NEXPIncrease = round($P_Level1 * 3); $B_NEXPIncreaserandom = rand(round($P_Level1 / 2), round($P_Level1)); //Define New Variables $P_NEXP1= round($B_NEXPIncrease + $B_NEXPIncreaserandom); $P_MHP1= round($B_HPIncrease + $P_MHP1); $P_ATK1= round($B_ATKIncrease + $P_ATK1); $P_DEF1= round($B_DEFIncrease + $P_DEF1); $P_SATK1= round($B_SPLATKIncrease + $P_SATK1); $P_SDEF1= round($B_SPLDEFIncrease + $P_SDEF1); //Define New Variables $P_HP1= $P_MHP1; //Define Sentence Variables $B_LevelSentence1="Your $P_Name1 has grown to Level <b>$P_Level1</b>!<br /><br /><u><b>Stats:</b></u><br /><b>HP:</b> +$B_HPIncrease<br /><b>ATK:</b> +$B_ATKIncrease<br /><b>DEF:</b> +$B_DEFIncrease<br /><b>SPLATK:</b> +$B_SPLATKIncrease<br /><b>SPLDEF:</b> +$B_SPLDEFIncrease<br />"; } mysql_query("UPDATE Pokémon SET P_Name='$P_Name1', P_Sprite='$P_Sprite1', P_Level='$P_Level1', P_EXP='$P_EXP1', P_NEXP='$P_NEXP1', P_HP='$P_HP1', P_MHP='$P_MHP1', P_MP='$P_MP1', P_MMP='$P_MMP1', P_ATK='$P_ATK1', P_DEF='$P_DEF1', P_SPLATK='$P_SPLATK1', P_SPLDEF='$P_SPLDEF1', P_SPD='$P_SPD1', P_Type='$P_Type1', P_Happiness='$P_Happiness1', P_BattleWins='$P_BattleWins1', P_BattleLosses='$P_BattleLosses1', P_TotalBattles='$P_TotalBattles1', P_EvolutionLevel='$P_EvolutionLevel1', P_EvolveTo='$P_EvolveTo1', P_Move1='$P_Move1_1', P_Move2='$P_Move2_1', P_Move3='$P_Move3_1', P_Move4='$P_Move4_1' WHERE P_ID='$P_ID1' LIMIT 1"); } if($P_HP1 = 0); { echo "You have lost"; header("location: index.php"); } } } } } } //Include Footer File include("bottom.php"); ?> Quote Link to comment Share on other sites More sharing options...
awpti Posted November 24, 2008 Share Posted November 24, 2008 Please tab out and format your code according to accepted standards. It is unreadable in this form. Also, we would need all the files, including database structure and filler content to know the true location of the problem. As it stands, there is nothing to look at. Have you checked the log files? Quote Link to comment Share on other sites More sharing options...
blueman378 Posted November 24, 2008 Share Posted November 24, 2008 it displays nothing for some reason.. Nothing at all? not even any errors? do you have error reporting turned on? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted November 24, 2008 Author Share Posted November 24, 2008 Error reporting? Ehh, I was getting errors all the time and I fixed them all, now it shows the layout but no content in the 'content' section (which is all that code right there) Quote Link to comment Share on other sites More sharing options...
trq Posted November 24, 2008 Share Posted November 24, 2008 Been said before but you need to indent your code if you expect programmers to read it. Quote Link to comment Share on other sites More sharing options...
.josh Posted November 25, 2008 Share Posted November 25, 2008 If error reporting is turned on and you are getting no errors then probably I can assume that all your code that echoes stuff out is in some kind of condition or other. I didn't actually look because I'm not gonna bother looking at 800 lines of unindented code. Start at the first condition and remove it. If still nothing happens, move on to the next one. That should probably help narrow your problem down. And if you do find the problem condition and can't figure out why it's causing problems, you can post just that, instead of 800 lines of code. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted November 25, 2008 Author Share Posted November 25, 2008 I know this is a noobie question.. But where do you start and end an indent. Is it like this <?PHP if(condition) { Content } else { Content } or what? Quote Link to comment Share on other sites More sharing options...
.josh Posted November 25, 2008 Share Posted November 25, 2008 That's acceptable; a lot of people do that. My preference: if (condition) { // code } else { // code } // end if..else condition for (expression1) { // code for (expression2) { // code if (condition1) { // code } // end if condition1 } // end for expression2 } // end for expression1 How you indent it is a matter of style. Important thing is that you indent it. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted November 25, 2008 Author Share Posted November 25, 2008 Hows this <?PHP include('Connect.php'); include('top.php'); include('pokeinfo.php'); if (!isset($_COOKIE['UserID'])) { $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); echo "Sorry, you are not logged in. <a href='Login.php'>Login now</a>"; include('bottom.php'); exit; } mysql_query("UPDATE Battle_Information SET Battle = 'True' WHERE ID = '$ID'"); $BI_Enemy_Attack="20"; $BI_Enemy_Special_Attack="20"; $BI_Enemy_Defense="20"; $BI_Enemy_Special_Defense="20"; function Battle_Unset() { mysql_query("UPDATE Battle_Information SET Battle = 'False' WHERE ID = '$ID'"); } $Result887 = mysql_query("SELECT * FROM Battle_Information"); $Rows887 = mysql_fetch_array($Result887); $Battle = $Rows887['Battle']; if($Battle != "True") { echo "Sorry you are not in a battle."; } else { //Check for errors //If HP is 0 if($P_MHP1=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; if($P_NEXP1=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; //Enemy Errors //If HP is 0 if($E_MHP=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; if($E_NEXP=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; //Define Dead Variables $B_Dead= 0; //Find Dead Values if($P_HP1== 0 || $P_Name1=="None") { $B_Dead= round($B_Dead + 1); } { //If All Pokémon Have Fainted if($B_Dead=="1") { echo "You have lost.. <html> <FORM method='GET' action='index.php' target='_blank'> <input type='submit' name='Lost' value='Continue'> </html>"; Battle_Unset(); } } include('bottom.php'); exit; $B_Result3= mysql_query("SELECT * FROM pokemon_info WHERE pokemon_name='$P_Name1' LIMIT 1"); $B_Rows3= mysql_fetch_array($B_Result3); //If Rows Are Empty if(empty($B_Rows3)) { //Display Message echo "Sorry there is an error."; } Battle_Unset(); include('bottom.php'); exit; //Find Rows $B_Result10= mysql_query("SELECT * FROM Battle_Information"); $B_Rows10= mysql_fetch_array($B_Result10); $E_ID = $B_Rows10['BI_Enemy_ID']; $E_Name = $B_Rows10['BI_Enemy_Name']; $EP = $B_Rows10['BI_Enemy_Pokemon']; $EP_Attack1 = $B_Rows10['BI_Enemy_Pokemon_Attack1']; $EP_Attack2 = $B_Rows10['BI_Enemy_Pokemon_Attack2']; $EP_Attack3 = $B_Rows10['BI_Enemy_Pokemon_Attack3']; $EP_Attack4 = $B_Rows10['BI_Enemy_Pokemon_Attack4']; $EP_Name = $B_Rows10['BI_Enemy_Pokemon_Name']; $EP_Attack = $B_Rows10['BI_Enemy_Pokemon_Attack']; $EP_Defense = $B_Rows10['BI_Enemy_Pokemon_Defense']; $EP_HP = $B_Rows10['BI_Enemy_Pokemon_HP']; $EP_MHP = $B_Rows10['BI_Enemy_Pokemon_MHP']; $EP_IMG = $B_Rows10['BI_Enemy_Pokemon_IMG']; $EP_Gender = $B_Rows10['BI_Enemy_Pokemon_Gender']; $EP_Level = $B_Rows10['BI_Enemy_Pokemon_Level']; $EP_EXP = $B_Rows10['BI_Enemy_Pokemon_EXP']; $EP_NEXP = $B_Rows10['BI_Enemy_Pokemon_NEXP']; $EP_GenderS = $B_Rows10['BI_Enemy_Pokemon_Gender_Sign']; $EP_SATK = $B_Rows10['BI_Enemy_Pokemon_Special_Attack']; $EP_SDEF = $B_Rows10['BI_Enemy_Pokemon_Special_Defense']; $EP_Type = $B_Rows10['BI_Enemy_Pokemon_Type']; $EP_Type2 = $B_Rows10['BI_Enemy_Pokemon_Type2']; $B_Result4= mysql_query("SELECT * FROM pokemon_info WHERE pokemon_name='$EP_Name' LIMIT 1"); $B_Rows4= mysql_fetch_array($B_Result4); //If Rows Are Empty if(empty($B_Rows4)) { //Display Message echo "There is an error."; Battle_Unset(); include('bottom.php'); exit; } //Define New Variables $B_Success="You have not performed an action as of yet. Please choose an action above."; //Display Form echo "<form action='battle.php' method='POST' name='BPOST'> <input type='hidden' name='B_Submit' value='1'> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav_header' align='center' width='100%'>"; //Display Content echo "$UserName's $P_Name1 Versus $E_Name's $CB_PName"; //Continue Form echo "</td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='50%'> <b>$P_Name1</b> </td> <td class='tnav' align='center' width='50%'> <b>$EP_Name</b> </td> </tr><tr> <td class='tnav' align='center' width='50%'> Level $P_Level1 (EXP: $P_EXP1/$P_NEXP1) </td> <td class='tnav' align='center' width='50%'> Level $EP_Level (EXP: $EP_EXP/$EP_NEXP) </td> </tr><tr> <td class='tnav' align='center' width='50%'> <div class='bar' align='left' width='50px'><img src='/EXP_Bar1.png' style='height: 7px; width: $B_EXPPercentage1%' title='EXP: $P_EXP1/$P_NEXP1 ($B_EXPPercentage1%)' alt=''></div> </td> <td class='tnav' align='center' width='50%'> <div class='bar' align='left' width='50px'><img src='/EXP_Bar1.png' style='height: 7px; width: $B_EXPPercentage2%' title='EXP: $EP_EXP/$EP_NEXP ($B_EXPPercentage2%)' alt=''></div> </td> </tr><tr> <td class='tnav' align='center' width='50%'> <img src='$P_Image1' title='$P_Name1' alt='$P_Name1'> </td> <td class='tnav' align='center' width='50%'> <img src='$EP_IMG' title='$EP_Name' alt='$EP_Name'> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='25%'> <b>HP: $P_HP1/$P_MHP1</b> </td> <td class='tnav' align='center' width='25%'> <b>HP: $EP_PHP/$EP_MHP</b> </td> </tr><tr> <td class='tnav' align='center' width='25%'> <div class='bar' align='left' width='25px'><img src='/HP_Bar1.png' style='height: 11px; width: $B_HPPercentage1%' title='HP: $P_HP1/$P_MHP1 ($B_HPPercentage1%)' alt='HP: $P_HP1/$P_MHP1 ($B_HPPercentage1%)'></div> </td> <td class='tnav' align='center' width='25%'> <div class='bar' align='left' width='25px'><img src='/HP_Bar1.png' style='height: 11px; width: $B_HPPercentage2%' title='HP: $CB_PHP/$CB_PMHP ($B_HPPercentage2%)' alt='HP: $CB_PHP/$CB_PMHP ($B_HPPercentage2%)'></div> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='25%'> <b>Attacks</b> </td> <td class='tnav' align='center' width='25%'> <b>Change Party</b> </td> <td class='tnav' align='center' width='25%'> <b>Item</b> </td> <td class='tnav' align='center' width='25%'> <b>Escape</b> </td> </tr><tr> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Attack' checked onclick=\"B_Form$Name.B_Item.disabled= false; B_Form$Name.B_Attack.disabled= false; B_Form$Name.B_Switch.disabled= true;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Change Party' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= false;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Item' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= true;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Escape' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= true;\"> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='50%'> <b>Your Inventory</b> </td> <td class='tnav' align='center' width='50%'> <b>$P_Name1's Attacks</b> </td> </tr><tr> //Continue Form <td class='tnav' align='center' width='50%'> <select name='B_Attack'>"; //If Session Is Set if(isset($_SESSION['B_PreviousMove'])) { //Define Session Variables $B_PreviousMove= $_SESSION['B_PreviousMove']; //If Previous Move Is Invalid if($B_PreviousMove < 1 || $B_PreviousMove > 5) { //Define New Variables $B_PreviousMove= 1; } //Display Information echo "<option value='$B_PreviousMove'>Previous Move</option>"; } //Continue Form echo "<option value='1'>$P_Move1_1 </option> <option value='2'>$P_Move2_1 </option> <option value='3'>$P_Move3_1 </option> <option value='4'>$P_Move4_1 </option> </select> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='100%'> <b>Current Turn</b> </td> </tr><tr> <td class='tnav' align='center' width='100%'> $B_Success </td> </tr><tr> <td class='tnav' align='center' width='100%'> <b>Change Party</b> </td> </tr><tr> <td class='tnav' align='center' width='100%'> <select name='B_Switch' disabled> <option value='0' onclick=\"B_Form$Name.B_Action[0].disabled= false; B_Form$Name.B_Action[1].disabled= false; B_Form$Name.B_Action[3].disabled= false;\">Don't Change Party</option> <option value='2' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name2 (LV: $P_Level2; HP: $P_HP2/$P_MHP2; MP: $P_MP2/$P_MMP2)</option> <option value='3' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name3 (LV: $P_Level3; HP: $P_HP3/$P_MHP3; MP: $P_MP3/$P_MMP3)</option> <option value='4' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name4 (LV: $P_Level4; HP: $P_HP4/$P_MHP4; MP: $P_MP4/$P_MMP4)</option> <option value='5' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name5 (LV: $P_Level5; HP: $P_HP5/$P_MHP5; MP: $P_MP5/$P_MMP5)</option> <option value='6' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name6 (LV: $P_Level6; HP: $P_HP6/$P_MHP6; MP: $P_MP6/$P_MMP6)</option> </select> </td> </tr><tr> <td class='tnav' align='center' width='100%'> <input type='submit' name='B_Submit2$Name' value='Continue$Dots' class='inputform' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"> </td> </tr></table>"; $B_Submit= $_POST['B_Submit']; $B_Action= $_POST['B_Action']; $B_Item= $_POST['B_Item']; $B_Attack= $_POST['B_Attack']; $B_Switch= $_POST['B_Switch']; $B_Action= mysql_real_escape_string($B_Action); $B_Item= mysql_real_escape_string($B_Item); $B_Attack= mysql_real_escape_string($B_Attack); $B_Switch= mysql_real_escape_string($B_Switch); //If Action Is Escape if($B_Action=="Escape") { //Define Sessions Define_Session("B_Submit", "True"); Define_Session("B_Success", "You have successfully escaped the enemy.<br /><br /><a href='index.php'>[ RPG Homepage ]</a><br /><a href='story_mode.php'>[ Story Mode ]</a><br /><a href='battle_a_trainer.php'>[ Battle A Trainer ]</a><br /><a href='pokemon_maps.php'>[ Pokémon Maps ]</a><br /><a href='pokemon_center.php'>[ Pokémon Center ]</a>"); Define_Session("B_Status", "Escaped"); //Redirect User header("location: battle.php"); //Exit Page exit; } //If HP Exceeds Maximum HP if($P_HP1 > $P_MHP1) { //Define New Variables $P_HP1= $P_MHP1; } //If MP Exceeds Maximum MP if($P_MP1 > $P_MMP1) { //Define New Variables $P_MP1= $P_MMP1; } //If Action Is Change Party elseif($B_Action=="Change Party") { //If Specified Slot Is Not Valid if($B_Switch < 2 || $B_Switch > 6) { echo "The slot is invalid"; //Redirect User header("location: battle.php"); //Exit Page exit; } //Find Rows $B_Result8= mysql_query("SELECT * FROM pokemon_info WHERE User_ID='$ID' AND pokemon_slot='$B_Switch' LIMIT 1"); $B_Rows8= mysql_fetch_array($B_Result8); //Define Pokémon Variables $PD_ID= $B_Rows8['pokemon_id']; $PD_Name= $B_Rows8['pokemon_name']; $PD_Sprite= $B_Rows8['pokemon_image']; //If Rows Are Empty if(empty($B_Rows8)) { echo "Sorry, the Pokemon seems to be unexistent."; //Redirect User header("location: battle.php"); //Exit Page exit; } //Update Pokémon Information mysql_query("UPDATE pokemon_info SET pokemon_slot='$B_Switch' WHERE User_ID='$ID' AND pokemon_slot='1' LIMIT 1"); //Update Pokémon Information mysql_query("UPDATE Pokémon SET pokemon_slot='1' WHERE User_ID='$ID' AND pokemon_id='$PD_ID' LIMIT 1"); echo "The pokemon have switched!"; //Destroy Sessions unset($_SESSION['B_PreviousMove']); //Redirect User header("location: battle.php"); //Exit Page exit; } else { //Declare B_BeginAttack Function function B_BeginAttack($BA_AttackEnemy) { //Define Globalized Variables global $ID; global $UserName; global $P_ID1; global $P_Name1; global $P_Name2; global $P_Name3; global $P_Name4; global $P_Name5; global $P_Name6; global $P_Image1; global $P_Level1; global $P_EXP1; global $P_NEXP1; global $P_HP1; global $P_HP2; global $P_HP3; global $P_HP4; global $P_HP5; global $P_HP6; global $P_MHP1; global $P_MP1; global $P_MMP1; global $P_ATK1; global $P_SATK1; global $P_DEF1; global $P_SDEF1; global $P_Type; global $P_Type21; global $P_Attack11; global $P_Attack21; global $P_Attack31; global $P_Attack41; global $E_ID; global $E_Type; global $E_Name; global $EP_ID; global $EP_Name; global $EP_IMG; global $EP_Level; global $EP_EXP; global $EP_NEXP; global $EP_HP; global $EP_MHP; global $EP_ATK; global $EP_DEF; global $EP_SATK; global $EP_SDEF; global $EP_Type; global $EP_Type2; global $EP_Gender; global $EP_GenderS; global $EP_Attack1; global $EP_Attack2; global $EP_Attack3; global $EP_Attack4; global $B_Item; global $B_Attack; global $B_Switch; //Define Random Variables $B_EnemysAttack= rand(1, 4); $Random_EXP= rand(round(($EP_Level / ), round(($EP_Level / 4))); $B_RandomMultiEXP= rand(2, 3); $B_DividedEXP= rand(3, 7); $B_HPIncrease= rand(2, 3); if($P_AD=="Attack") { $B_ATKIncrease= rand(3, 5); } else { $B_ATKIncrease= rand(2, 5); } if($P_AD=="Defense") { $B_DEFIncrease= rand(3, 5); } else { $B_DEFIncrease= rand(2, 5); } if($P_AD=="SpecialAttack") { $B_SATKIncrease= rand(3, 5); } else { $B_SATKIncrease= rand(2, 5); } if($P_AD=="SpecialDefense") { $B_SDEFIncrease= rand(3, 5); } else { $B_SDEFIncrease= rand(2, 5); } //If Attack Enemy Is True if($BA_AttackEnemy=="True") { //Define Sessions Define_Session("B_PreviousMove", $B_Attack); //If First Move Is Chosen if($B_Attack== 1) { //Define Move Variables $B_Move= $P_Attack11; } //If Second Move Is Chosen elseif($B_Attack== 2) { //Define Move Variables $B_Move= $P_Attack21; } //If Third Move Is Chosen elseif($B_Attack== 3) { //Define Move Variables $B_Move= $P_Attack31; } //If Fourth Move Is Chosen else { //Define Move Variables $B_Move= $P_Attack41; } //Find Rows $B_Result9= mysql_query("SELECT * FROM Move_Data WHERE MD_Name='$B_Move' LIMIT 1"); $B_Rows9= mysql_fetch_array($B_Result9); //Define Move Data Variables $MD_Name= $B_Rows9['MD_Name']; $MD_Type= $B_Rows9['MD_Type']; $MD_Power= $B_Rows9['Power']; $MD_Physical= $B_Rows9['Physical']; $MD_Special= $B_Rows9['Special']; //If Rows Are Empty if(empty($B_Rows9)) { //Define Sessions Define_Session("B_Submit", "True"); Define_Session("B_Success", "Sorry, the specified move does not appear to be existant; please report this."); //Redirect User header("location: battle.php"); //Exit Page exit; } if($MD_Physical=="Yes") { //Define Damage Variables $B_YourDamage= round(($MD_Power / 1) * ($P_ATK1 / 1) / ($EP_DEF / 1) / (5 / 1) + ($P_Level1)); //If Your Damage Is Invalid if($B_YourDamage < 0) { //Define New Variables $B_YourDamage= 0; } } else { //Define Damage Variables $B_YourDamage= round(($MD_Power / 1) * ($P_SATK1 / 1) / ($EP_SDEF / 1) / (5 / 1) + ($P_Level1)); //If Your Damage Is Invalid if($B_YourDamage < 0) { //Define New Variables $B_YourDamage= 0; } echo "You have done $B_YourDamage Damage"; $EP_HP= round($EP_HP - $B_YourDamage); } //If Enemy's HP Is Below Zero if($EP_HP < 0) { //Define New Variables $EP_HP= 0; } //If Enemy's HP Is Too High elseif($EP_HP > $EP_MHP) { //Define New Variables $EP_HP= $EP_MHP; } } //If Enemy Has Not Fainted if($EP_HP != 0) { //If First Move Is Chosen if($B_EnemysAttack== 1) { //Define Move Variables $B_EnemysMove= $EP_Attack1; } //If Second Move Is Chosen elseif($B_EnemysAttack== 2) { //Define Move Variables $B_EnemysMove= $EP_Attack2; } //If Third Move Is Chosen elseif($B_EnemysAttack== 3) { //Define Move Variables $B_EnemysMove= $EP_Attack3; } //If Fourth Move Is Chosen elseif($B_EnemysAttack== 4) { //Define Move Variables $B_EnemysMove= $EP_Attack4; } $B_Result10= mysql_query("SELECT * FROM Move_Data WHERE MD_Name='$B_EnemysMove' LIMIT 1"); $B_Rows10= mysql_fetch_array($B_Result10); //Define Move Data Variables $MD_EnemysName= $B_Rows10['MD_Name']; $MD_EnemysSpecial= $B_Rows10['MD_Special']; $MD_EnemysPhysical= $B_Rows10['MD_Physical']; $MD_EnemysPower= $B_Rows10['MD_Power']; $Dodge_Rand= rand(1, 5); $Counter_Rand= rand(1, 5); $B_Submit10= $_POST['B_Submit10']; $B_Submit11= $_POST['B_Submit11']; $B_Submit10= mysql_real_escape_string($B_Submit10); $B_Submit11= mysql_real_escape_string($B_Submit11); echo "The enemy is using $B_EnemysMove<br><FORM method='GET' action='battle.php' target='_blank'> <input type='submit' name='B_Submit10' value='Dodge'><br> <input type='submit' name='B_Submit11' value='Counter'>"; if(isset($B_Submit10)) { if($Dodge_Rand=="5") { echo "You have successfully dodged the attack!"; } else { //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_ATK / 1) / ($P_DEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); } } else { if($Counter_Rand=="5") { echo "You have pulled off a counter attack you have done $B_YourDamage Damage"; //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_ATK / 1) / ($P_DEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); } else { //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) + ($EP_ATK / 1) - ($P_DEF1 / 1)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); //If Your HP Is Below Zero if($P_HP1 < 0) { //Define New Variables $P_HP1= 0; } //If Your HP Is Too High elseif($P_HP1 > $P_MHP1) { //Define New Variables $P_HP1= $P_MHP1; } } //If Enemy Has Fainted if($EP_HP== 0) { //Define Random Variables $B_GainedCredits= rand(100, 400); //Define New Variables $U_DiamondCredits= round($U_DiamondCredits + $B_GainedCredits); //Define Formatted Variables $B_DisplayGainedCredits=="$B_GainedCredits"; //Define EXP Variables $B_GainedEXP= round(($EP_HP) * ($EP_Level) / (15 / 1)); //Define New Variables $P_EXP1= round($P_EXP1 + $B_GainedEXP); //Define Sentence Variables $B_EXPSentence1="<br />Your $P_Name1 has gained <b>$B_GainedEXP</b> Experience Point(s)!"; //If Your EXP Is Below Zero if($P_EXP1 < 0) { //Define New Variables $P_EXP1= 0; } //If Your EXP Is Too High elseif($P_EXP1 >= $P_NEXP1) { //Define New Variables $P_Level1= round($P_Level1 + 1); $P_EXP1= round($P_EXP1 - $P_NEXP1); $B_NEXPIncrease = round($P_Level1 * 3); $B_NEXPIncreaserandom = rand(round($P_Level1 / 2), round($P_Level1)); //Define New Variables $P_NEXP1= round($B_NEXPIncrease + $B_NEXPIncreaserandom); $P_MHP1= round($B_HPIncrease + $P_MHP1); $P_ATK1= round($B_ATKIncrease + $P_ATK1); $P_DEF1= round($B_DEFIncrease + $P_DEF1); $P_SATK1= round($B_SPLATKIncrease + $P_SATK1); $P_SDEF1= round($B_SPLDEFIncrease + $P_SDEF1); //Define New Variables $P_HP1= $P_MHP1; //Define Sentence Variables $B_LevelSentence1="Your $P_Name1 has grown to Level <b>$P_Level1</b>!<br /><br /><u><b>Stats:</b></u><br /><b>HP:</b> +$B_HPIncrease<br /><b>ATK:</b> +$B_ATKIncrease<br /><b>DEF:</b> +$B_DEFIncrease<br /><b>SPLATK:</b> +$B_SPLATKIncrease<br /><b>SPLDEF:</b> +$B_SPLDEFIncrease<br />"; } mysql_query("UPDATE Pokémon SET P_Name='$P_Name1', P_Sprite='$P_Sprite1', P_Level='$P_Level1', P_EXP='$P_EXP1', P_NEXP='$P_NEXP1', P_HP='$P_HP1', P_MHP='$P_MHP1', P_MP='$P_MP1', P_MMP='$P_MMP1', P_ATK='$P_ATK1', P_DEF='$P_DEF1', P_SPLATK='$P_SPLATK1', P_SPLDEF='$P_SPLDEF1', P_SPD='$P_SPD1', P_Type='$P_Type1', P_Happiness='$P_Happiness1', P_BattleWins='$P_BattleWins1', P_BattleLosses='$P_BattleLosses1', P_TotalBattles='$P_TotalBattles1', P_EvolutionLevel='$P_EvolutionLevel1', P_EvolveTo='$P_EvolveTo1', P_Move1='$P_Move1_1', P_Move2='$P_Move2_1', P_Move3='$P_Move3_1', P_Move4='$P_Move4_1' WHERE P_ID='$P_ID1' LIMIT 1"); } if($P_HP1 = 0); { echo "You have lost"; header("location: index.php"); } } } } } } //Include Footer File include("bottom.php"); ?> Quote Link to comment Share on other sites More sharing options...
.josh Posted November 25, 2008 Share Posted November 25, 2008 That's 100% better. So...have you tried commenting out one condition at a time, yet? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted November 25, 2008 Author Share Posted November 25, 2008 There are like 300 conditions in there and it would take longer than the script itself to do that. Plus.. If the condition isnt true, it should say the message, if it is true it should skip to the next conditions, if the conditions are false it will display an error like "Error something is wrong refresh and try again" and if theya re true it will appear as it says it should. Also, where it displays the tables and such, as logn as there are no errors, it should automatically display them. Quote Link to comment Share on other sites More sharing options...
trq Posted November 25, 2008 Share Posted November 25, 2008 There are like 300 conditions in there and it would take longer than the script itself to do that. So, do you want us to do it for you? This is all part of debuging your code. You need to narrow down the problem. Quote Link to comment Share on other sites More sharing options...
.josh Posted November 25, 2008 Share Posted November 25, 2008 You seemed to think people would go through your code when it was unindented. You've done really well in indenting it, but that was a suggestion to help you out, in general. I hope you weren't expecting people to go through 800 lines of code simply because you indented it. And anyways, we couldn't go through and test the conditions for you even if we wanted to. We don't have access to anything that's bringing info from includes, db queries etc... to the table, to even test whether they work or not. Now I know that you didn't come here to be told what you're doing wrong, as far as forum etiquette goes, or even being told how to be a better coder. Your script doesn't work, and you're looking for help getting it fixed. So here it is: Considering the page is blank, it's more likely one of your first conditions, which encapsulates everything else, that is failing. I'm willing to bet that you are not going to have to go through anywhere near all 300 of those conditions before you find the one bugging. I'm sorry, I wish there was some magic wand to wave, but there's not. I can't really think of a better way to go about finding the bug, can you? Quote Link to comment Share on other sites More sharing options...
.josh Posted November 25, 2008 Share Posted November 25, 2008 Also, where it displays the tables and such, as [long] as there are no errors, it should automatically display them. Look at what you just said. If there are no other conditions that prevent stuff from being displayed, and yet there is nothing being displayed, then it stands to reason that there are errors there. I suggest you start there. Quote Link to comment Share on other sites More sharing options...
premiso Posted November 25, 2008 Share Posted November 25, 2008 Try error reporting before trecking through the conditions: <?PHP error_reporting(E_ALL); ini_set('display_errors', 1); include('Connect.php'); include('top.php'); include('pokeinfo.php'); if (!isset($_COOKIE['UserID'])) { $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); echo "Sorry, you are not logged in. <a href='Login.php'>Login now</a>"; include('bottom.php'); exit; } // etcc ?> If that pulls up nothing, good luck going through each condition. I had to do that many times. That is why I generally check code at stages and make sure it works instead of coding 300 conditions at once and having to find a needle in a haystack. You live you learn. Just hope you don't repeat the same mistakes in the future. Quote Link to comment Share on other sites More sharing options...
peranha Posted November 25, 2008 Share Posted November 25, 2008 May be a stupid answer, but can you have 2 conditions after an if statement, I have never seen it before. //Find Dead Values if($P_HP1== 0 || $P_Name1=="None") { $B_Dead= round($B_Dead + 1); } { //If All Pokémon Have Fainted if($B_Dead=="1") { echo "You have lost.. <html> <FORM method='GET' action='index.php' target='_blank'> <input type='submit' name='Lost' value='Continue'> </html>"; Battle_Unset(); } } Quote Link to comment Share on other sites More sharing options...
blueman378 Posted November 26, 2008 Share Posted November 26, 2008 try running this see what comes up: <?PHP include('Connect.php'); include('top.php'); include('pokeinfo.php'); if (!isset($_COOKIE['UserID'])) { $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); echo "Sorry, you are not logged in. <a href='Login.php'>Login now</a>"; include('bottom.php'); exit; } mysql_query("UPDATE Battle_Information SET Battle = 'True' WHERE ID = '$ID'") or die(mysql_error()); $BI_Enemy_Attack="20"; $BI_Enemy_Special_Attack="20"; $BI_Enemy_Defense="20"; $BI_Enemy_Special_Defense="20"; function Battle_Unset() { mysql_query("UPDATE Battle_Information SET Battle = 'False' WHERE ID = '$ID'") or die(mysql_error());; } $Result887 = mysql_query("SELECT * FROM Battle_Information") or die(mysql_error());; $Rows887 = mysql_fetch_array($Result887); $Battle = $Rows887['Battle']; if($Battle != "True") { echo "Sorry you are not in a battle."; } else { //Check for errors //If HP is 0 if($P_MHP1=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; if($P_NEXP1=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; //Enemy Errors //If HP is 0 if($E_MHP=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; if($E_NEXP=="0") { echo "There is an error. Wait a few seconds and try again, if this does not work report it."; } //Unset Session Battle_Unset(); include('bottom.php'); exit; //Define Dead Variables $B_Dead= 0; //Find Dead Values if($P_HP1== 0 || $P_Name1=="None") { $B_Dead= round($B_Dead + 1); } { //If All Pokémon Have Fainted if($B_Dead=="1") { echo "You have lost.. <html> <FORM method='GET' action='index.php' target='_blank'> <input type='submit' name='Lost' value='Continue'> </html>"; Battle_Unset(); } } include('bottom.php'); exit; $B_Result3= mysql_query("SELECT * FROM pokemon_info WHERE pokemon_name='$P_Name1' LIMIT 1") or die(mysql_error()); $B_Rows3= mysql_fetch_array($B_Result3); //If Rows Are Empty if(empty($B_Rows3)) { //Display Message echo "Sorry there is an error."; } Battle_Unset(); include('bottom.php'); exit; //Find Rows $B_Result10= mysql_query("SELECT * FROM Battle_Information") or die(mysql_error()); $B_Rows10= mysql_fetch_array($B_Result10); $E_ID = $B_Rows10['BI_Enemy_ID']; $E_Name = $B_Rows10['BI_Enemy_Name']; $EP = $B_Rows10['BI_Enemy_Pokemon']; $EP_Attack1 = $B_Rows10['BI_Enemy_Pokemon_Attack1']; $EP_Attack2 = $B_Rows10['BI_Enemy_Pokemon_Attack2']; $EP_Attack3 = $B_Rows10['BI_Enemy_Pokemon_Attack3']; $EP_Attack4 = $B_Rows10['BI_Enemy_Pokemon_Attack4']; $EP_Name = $B_Rows10['BI_Enemy_Pokemon_Name']; $EP_Attack = $B_Rows10['BI_Enemy_Pokemon_Attack']; $EP_Defense = $B_Rows10['BI_Enemy_Pokemon_Defense']; $EP_HP = $B_Rows10['BI_Enemy_Pokemon_HP']; $EP_MHP = $B_Rows10['BI_Enemy_Pokemon_MHP']; $EP_IMG = $B_Rows10['BI_Enemy_Pokemon_IMG']; $EP_Gender = $B_Rows10['BI_Enemy_Pokemon_Gender']; $EP_Level = $B_Rows10['BI_Enemy_Pokemon_Level']; $EP_EXP = $B_Rows10['BI_Enemy_Pokemon_EXP']; $EP_NEXP = $B_Rows10['BI_Enemy_Pokemon_NEXP']; $EP_GenderS = $B_Rows10['BI_Enemy_Pokemon_Gender_Sign']; $EP_SATK = $B_Rows10['BI_Enemy_Pokemon_Special_Attack']; $EP_SDEF = $B_Rows10['BI_Enemy_Pokemon_Special_Defense']; $EP_Type = $B_Rows10['BI_Enemy_Pokemon_Type']; $EP_Type2 = $B_Rows10['BI_Enemy_Pokemon_Type2']; $B_Result4= mysql_query("SELECT * FROM pokemon_info WHERE pokemon_name='$EP_Name' LIMIT 1") or die(mysql_error()); $B_Rows4= mysql_fetch_array($B_Result4); //If Rows Are Empty if(empty($B_Rows4)) { //Display Message echo "There is an error."; Battle_Unset(); include('bottom.php'); exit; } //Define New Variables $B_Success="You have not performed an action as of yet. Please choose an action above."; //Display Form echo "<form action='battle.php' method='POST' name='BPOST'> <input type='hidden' name='B_Submit' value='1'> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav_header' align='center' width='100%'>"; //Display Content echo "$UserName's $P_Name1 Versus $E_Name's $CB_PName"; //Continue Form echo "</td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='50%'> <b>$P_Name1</b> </td> <td class='tnav' align='center' width='50%'> <b>$EP_Name</b> </td> </tr><tr> <td class='tnav' align='center' width='50%'> Level $P_Level1 (EXP: $P_EXP1/$P_NEXP1) </td> <td class='tnav' align='center' width='50%'> Level $EP_Level (EXP: $EP_EXP/$EP_NEXP) </td> </tr><tr> <td class='tnav' align='center' width='50%'> <div class='bar' align='left' width='50px'><img src='/EXP_Bar1.png' style='height: 7px; width: $B_EXPPercentage1%' title='EXP: $P_EXP1/$P_NEXP1 ($B_EXPPercentage1%)' alt=''></div> </td> <td class='tnav' align='center' width='50%'> <div class='bar' align='left' width='50px'><img src='/EXP_Bar1.png' style='height: 7px; width: $B_EXPPercentage2%' title='EXP: $EP_EXP/$EP_NEXP ($B_EXPPercentage2%)' alt=''></div> </td> </tr><tr> <td class='tnav' align='center' width='50%'> <img src='$P_Image1' title='$P_Name1' alt='$P_Name1'> </td> <td class='tnav' align='center' width='50%'> <img src='$EP_IMG' title='$EP_Name' alt='$EP_Name'> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='25%'> <b>HP: $P_HP1/$P_MHP1</b> </td> <td class='tnav' align='center' width='25%'> <b>HP: $EP_PHP/$EP_MHP</b> </td> </tr><tr> <td class='tnav' align='center' width='25%'> <div class='bar' align='left' width='25px'><img src='/HP_Bar1.png' style='height: 11px; width: $B_HPPercentage1%' title='HP: $P_HP1/$P_MHP1 ($B_HPPercentage1%)' alt='HP: $P_HP1/$P_MHP1 ($B_HPPercentage1%)'></div> </td> <td class='tnav' align='center' width='25%'> <div class='bar' align='left' width='25px'><img src='/HP_Bar1.png' style='height: 11px; width: $B_HPPercentage2%' title='HP: $CB_PHP/$CB_PMHP ($B_HPPercentage2%)' alt='HP: $CB_PHP/$CB_PMHP ($B_HPPercentage2%)'></div> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='25%'> <b>Attacks</b> </td> <td class='tnav' align='center' width='25%'> <b>Change Party</b> </td> <td class='tnav' align='center' width='25%'> <b>Item</b> </td> <td class='tnav' align='center' width='25%'> <b>Escape</b> </td> </tr><tr> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Attack' checked onclick=\"B_Form$Name.B_Item.disabled= false; B_Form$Name.B_Attack.disabled= false; B_Form$Name.B_Switch.disabled= true;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Change Party' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= false;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Item' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= true;\"> </td> <td class='tnav' align='center' width='25%'> <input type='radio' name='B_Action' value='Escape' onclick=\"B_Form$Name.B_Item.disabled= true; B_Form$Name.B_Attack.disabled= true; B_Form$Name.B_Switch.disabled= true;\"> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='50%'> <b>Your Inventory</b> </td> <td class='tnav' align='center' width='50%'> <b>$P_Name1's Attacks</b> </td> </tr><tr> //Continue Form <td class='tnav' align='center' width='50%'> <select name='B_Attack'>"; //If Session Is Set if(isset($_SESSION['B_PreviousMove'])) { //Define Session Variables $B_PreviousMove= $_SESSION['B_PreviousMove']; //If Previous Move Is Invalid if($B_PreviousMove < 1 || $B_PreviousMove > 5) { //Define New Variables $B_PreviousMove= 1; } //Display Information echo "<option value='$B_PreviousMove'>Previous Move</option>"; } //Continue Form echo "<option value='1'>$P_Move1_1 </option> <option value='2'>$P_Move2_1 </option> <option value='3'>$P_Move3_1 </option> <option value='4'>$P_Move4_1 </option> </select> </td> </tr></table> <table class='tables' cellpadding='1' cellspacing='1' width='95%'><tr> <td class='tnav' align='center' width='100%'> <b>Current Turn</b> </td> </tr><tr> <td class='tnav' align='center' width='100%'> $B_Success </td> </tr><tr> <td class='tnav' align='center' width='100%'> <b>Change Party</b> </td> </tr><tr> <td class='tnav' align='center' width='100%'> <select name='B_Switch' disabled> <option value='0' onclick=\"B_Form$Name.B_Action[0].disabled= false; B_Form$Name.B_Action[1].disabled= false; B_Form$Name.B_Action[3].disabled= false;\">Don't Change Party</option> <option value='2' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name2 (LV: $P_Level2; HP: $P_HP2/$P_MHP2; MP: $P_MP2/$P_MMP2)</option> <option value='3' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name3 (LV: $P_Level3; HP: $P_HP3/$P_MHP3; MP: $P_MP3/$P_MMP3)</option> <option value='4' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name4 (LV: $P_Level4; HP: $P_HP4/$P_MHP4; MP: $P_MP4/$P_MMP4)</option> <option value='5' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name5 (LV: $P_Level5; HP: $P_HP5/$P_MHP5; MP: $P_MP5/$P_MMP5)</option> <option value='6' onclick=\"B_Form$Name.B_Action[0].disabled= true; B_Form$Name.B_Action[1].disabled= true; B_Form$Name.B_Action[3].disabled= true;\">$P_Name6 (LV: $P_Level6; HP: $P_HP6/$P_MHP6; MP: $P_MP6/$P_MMP6)</option> </select> </td> </tr><tr> <td class='tnav' align='center' width='100%'> <input type='submit' name='B_Submit2$Name' value='Continue$Dots' class='inputform' onclick=\"this.disabled='true'; this.value='Please Wait...'; this.form.submit();\"> </td> </tr></table>"; $B_Submit= $_POST['B_Submit']; $B_Action= $_POST['B_Action']; $B_Item= $_POST['B_Item']; $B_Attack= $_POST['B_Attack']; $B_Switch= $_POST['B_Switch']; $B_Action= mysql_real_escape_string($B_Action); $B_Item= mysql_real_escape_string($B_Item); $B_Attack= mysql_real_escape_string($B_Attack); $B_Switch= mysql_real_escape_string($B_Switch); //If Action Is Escape if($B_Action=="Escape") { //Define Sessions Define_Session("B_Submit", "True"); Define_Session("B_Success", "You have successfully escaped the enemy.<br /><br /><a href='index.php'>[ RPG Homepage ]</a><br /><a href='story_mode.php'>[ Story Mode ]</a><br /><a href='battle_a_trainer.php'>[ Battle A Trainer ]</a><br /><a href='pokemon_maps.php'>[ Pokémon Maps ]</a><br /><a href='pokemon_center.php'>[ Pokémon Center ]</a>"); Define_Session("B_Status", "Escaped"); //Redirect User header("location: battle.php"); //Exit Page exit; } //If HP Exceeds Maximum HP if($P_HP1 > $P_MHP1) { //Define New Variables $P_HP1= $P_MHP1; } //If MP Exceeds Maximum MP if($P_MP1 > $P_MMP1) { //Define New Variables $P_MP1= $P_MMP1; } //If Action Is Change Party elseif($B_Action=="Change Party") { //If Specified Slot Is Not Valid if($B_Switch < 2 || $B_Switch > 6) { echo "The slot is invalid"; //Redirect User header("location: battle.php"); //Exit Page exit; } //Find Rows $B_Result8= mysql_query("SELECT * FROM pokemon_info WHERE User_ID='$ID' AND pokemon_slot='$B_Switch' LIMIT 1") or die(mysql_error()); $B_Rows8= mysql_fetch_array($B_Result8); //Define Pokémon Variables $PD_ID= $B_Rows8['pokemon_id']; $PD_Name= $B_Rows8['pokemon_name']; $PD_Sprite= $B_Rows8['pokemon_image']; //If Rows Are Empty if(empty($B_Rows8)) { echo "Sorry, the Pokemon seems to be unexistent."; //Redirect User header("location: battle.php"); //Exit Page exit; } //Update Pokémon Information mysql_query("UPDATE pokemon_info SET pokemon_slot='$B_Switch' WHERE User_ID='$ID' AND pokemon_slot='1' LIMIT 1"); //Update Pokémon Information mysql_query("UPDATE Pokémon SET pokemon_slot='1' WHERE User_ID='$ID' AND pokemon_id='$PD_ID' LIMIT 1"); echo "The pokemon have switched!"; //Destroy Sessions unset($_SESSION['B_PreviousMove']); //Redirect User header("location: battle.php"); //Exit Page exit; } else { //Declare B_BeginAttack Function function B_BeginAttack($BA_AttackEnemy) { //Define Globalized Variables global $ID; global $UserName; global $P_ID1; global $P_Name1; global $P_Name2; global $P_Name3; global $P_Name4; global $P_Name5; global $P_Name6; global $P_Image1; global $P_Level1; global $P_EXP1; global $P_NEXP1; global $P_HP1; global $P_HP2; global $P_HP3; global $P_HP4; global $P_HP5; global $P_HP6; global $P_MHP1; global $P_MP1; global $P_MMP1; global $P_ATK1; global $P_SATK1; global $P_DEF1; global $P_SDEF1; global $P_Type; global $P_Type21; global $P_Attack11; global $P_Attack21; global $P_Attack31; global $P_Attack41; global $E_ID; global $E_Type; global $E_Name; global $EP_ID; global $EP_Name; global $EP_IMG; global $EP_Level; global $EP_EXP; global $EP_NEXP; global $EP_HP; global $EP_MHP; global $EP_ATK; global $EP_DEF; global $EP_SATK; global $EP_SDEF; global $EP_Type; global $EP_Type2; global $EP_Gender; global $EP_GenderS; global $EP_Attack1; global $EP_Attack2; global $EP_Attack3; global $EP_Attack4; global $B_Item; global $B_Attack; global $B_Switch; //Define Random Variables $B_EnemysAttack= rand(1, 4); $Random_EXP= rand(round(($EP_Level / ), round(($EP_Level / 4))); $B_RandomMultiEXP= rand(2, 3); $B_DividedEXP= rand(3, 7); $B_HPIncrease= rand(2, 3); if($P_AD=="Attack") { $B_ATKIncrease= rand(3, 5); } else { $B_ATKIncrease= rand(2, 5); } if($P_AD=="Defense") { $B_DEFIncrease= rand(3, 5); } else { $B_DEFIncrease= rand(2, 5); } if($P_AD=="SpecialAttack") { $B_SATKIncrease= rand(3, 5); } else { $B_SATKIncrease= rand(2, 5); } if($P_AD=="SpecialDefense") { $B_SDEFIncrease= rand(3, 5); } else { $B_SDEFIncrease= rand(2, 5); } //If Attack Enemy Is True if($BA_AttackEnemy=="True") { //Define Sessions Define_Session("B_PreviousMove", $B_Attack); //If First Move Is Chosen if($B_Attack== 1) { //Define Move Variables $B_Move= $P_Attack11; } //If Second Move Is Chosen elseif($B_Attack== 2) { //Define Move Variables $B_Move= $P_Attack21; } //If Third Move Is Chosen elseif($B_Attack== 3) { //Define Move Variables $B_Move= $P_Attack31; } //If Fourth Move Is Chosen else { //Define Move Variables $B_Move= $P_Attack41; } //Find Rows $B_Result9= mysql_query("SELECT * FROM Move_Data WHERE MD_Name='$B_Move' LIMIT 1") or die(mysql_error()); $B_Rows9= mysql_fetch_array($B_Result9); //Define Move Data Variables $MD_Name= $B_Rows9['MD_Name']; $MD_Type= $B_Rows9['MD_Type']; $MD_Power= $B_Rows9['Power']; $MD_Physical= $B_Rows9['Physical']; $MD_Special= $B_Rows9['Special']; //If Rows Are Empty if(empty($B_Rows9)) { //Define Sessions Define_Session("B_Submit", "True"); Define_Session("B_Success", "Sorry, the specified move does not appear to be existant; please report this."); //Redirect User header("location: battle.php"); //Exit Page exit; } if($MD_Physical=="Yes") { //Define Damage Variables $B_YourDamage= round(($MD_Power / 1) * ($P_ATK1 / 1) / ($EP_DEF / 1) / (5 / 1) + ($P_Level1)); //If Your Damage Is Invalid if($B_YourDamage < 0) { //Define New Variables $B_YourDamage= 0; } } else { //Define Damage Variables $B_YourDamage= round(($MD_Power / 1) * ($P_SATK1 / 1) / ($EP_SDEF / 1) / (5 / 1) + ($P_Level1)); //If Your Damage Is Invalid if($B_YourDamage < 0) { //Define New Variables $B_YourDamage= 0; } echo "You have done $B_YourDamage Damage"; $EP_HP= round($EP_HP - $B_YourDamage); } //If Enemy's HP Is Below Zero if($EP_HP < 0) { //Define New Variables $EP_HP= 0; } //If Enemy's HP Is Too High elseif($EP_HP > $EP_MHP) { //Define New Variables $EP_HP= $EP_MHP; } } //If Enemy Has Not Fainted if($EP_HP != 0) { //If First Move Is Chosen if($B_EnemysAttack== 1) { //Define Move Variables $B_EnemysMove= $EP_Attack1; } //If Second Move Is Chosen elseif($B_EnemysAttack== 2) { //Define Move Variables $B_EnemysMove= $EP_Attack2; } //If Third Move Is Chosen elseif($B_EnemysAttack== 3) { //Define Move Variables $B_EnemysMove= $EP_Attack3; } //If Fourth Move Is Chosen elseif($B_EnemysAttack== 4) { //Define Move Variables $B_EnemysMove= $EP_Attack4; } $B_Result10= mysql_query("SELECT * FROM Move_Data WHERE MD_Name='$B_EnemysMove' LIMIT 1") or die(mysql_error()); $B_Rows10= mysql_fetch_array($B_Result10); //Define Move Data Variables $MD_EnemysName= $B_Rows10['MD_Name']; $MD_EnemysSpecial= $B_Rows10['MD_Special']; $MD_EnemysPhysical= $B_Rows10['MD_Physical']; $MD_EnemysPower= $B_Rows10['MD_Power']; $Dodge_Rand= rand(1, 5); $Counter_Rand= rand(1, 5); $B_Submit10= $_POST['B_Submit10']; $B_Submit11= $_POST['B_Submit11']; $B_Submit10= mysql_real_escape_string($B_Submit10); $B_Submit11= mysql_real_escape_string($B_Submit11); echo "The enemy is using $B_EnemysMove<br><FORM method='GET' action='battle.php' target='_blank'> <input type='submit' name='B_Submit10' value='Dodge'><br> <input type='submit' name='B_Submit11' value='Counter'>"; if(isset($B_Submit10)) { if($Dodge_Rand=="5") { echo "You have successfully dodged the attack!"; } else { //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_ATK / 1) / ($P_DEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); } } else { if($Counter_Rand=="5") { echo "You have pulled off a counter attack you have done $B_YourDamage Damage"; //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_ATK / 1) / ($P_DEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); } else { //If Enemy's Move Is Physical if($MD_EnemysPhysical=="Yes") { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) + ($EP_ATK / 1) - ($P_DEF1 / 1)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } //If Enemy's Move Is Not Physical else { //Define Damage Variables $B_EnemysDamage= round(($MD_EnemysPower / 1) * ($EP_SATK / 1) / ($P_SDEF1 / 1) / (5 / 1) + ($EP_Level)); //If Enemy's Damage Is Invalid if($B_EnemysDamage < 0) { //Define New Variables $B_EnemysDamage= 0; } } echo "The enemy did $B_EnemysDamage Damage"; $P_HP1= round($P_HP1 - $B_EnemysDamage); //If Your HP Is Below Zero if($P_HP1 < 0) { //Define New Variables $P_HP1= 0; } //If Your HP Is Too High elseif($P_HP1 > $P_MHP1) { //Define New Variables $P_HP1= $P_MHP1; } } //If Enemy Has Fainted if($EP_HP== 0) { //Define Random Variables $B_GainedCredits= rand(100, 400); //Define New Variables $U_DiamondCredits= round($U_DiamondCredits + $B_GainedCredits); //Define Formatted Variables $B_DisplayGainedCredits=="$B_GainedCredits"; //Define EXP Variables $B_GainedEXP= round(($EP_HP) * ($EP_Level) / (15 / 1)); //Define New Variables $P_EXP1= round($P_EXP1 + $B_GainedEXP); //Define Sentence Variables $B_EXPSentence1="<br />Your $P_Name1 has gained <b>$B_GainedEXP</b> Experience Point(s)!"; //If Your EXP Is Below Zero if($P_EXP1 < 0) { //Define New Variables $P_EXP1= 0; } //If Your EXP Is Too High elseif($P_EXP1 >= $P_NEXP1) { //Define New Variables $P_Level1= round($P_Level1 + 1); $P_EXP1= round($P_EXP1 - $P_NEXP1); $B_NEXPIncrease = round($P_Level1 * 3); $B_NEXPIncreaserandom = rand(round($P_Level1 / 2), round($P_Level1)); //Define New Variables $P_NEXP1= round($B_NEXPIncrease + $B_NEXPIncreaserandom); $P_MHP1= round($B_HPIncrease + $P_MHP1); $P_ATK1= round($B_ATKIncrease + $P_ATK1); $P_DEF1= round($B_DEFIncrease + $P_DEF1); $P_SATK1= round($B_SPLATKIncrease + $P_SATK1); $P_SDEF1= round($B_SPLDEFIncrease + $P_SDEF1); //Define New Variables $P_HP1= $P_MHP1; //Define Sentence Variables $B_LevelSentence1="Your $P_Name1 has grown to Level <b>$P_Level1</b>!<br /><br /><u><b>Stats:</b></u><br /><b>HP:</b> +$B_HPIncrease<br /><b>ATK:</b> +$B_ATKIncrease<br /><b>DEF:</b> +$B_DEFIncrease<br /><b>SPLATK:</b> +$B_SPLATKIncrease<br /><b>SPLDEF:</b> +$B_SPLDEFIncrease<br />"; } mysql_query("UPDATE Pokémon SET P_Name='$P_Name1', P_Sprite='$P_Sprite1', P_Level='$P_Level1', P_EXP='$P_EXP1', P_NEXP='$P_NEXP1', P_HP='$P_HP1', P_MHP='$P_MHP1', P_MP='$P_MP1', P_MMP='$P_MMP1', P_ATK='$P_ATK1', P_DEF='$P_DEF1', P_SPLATK='$P_SPLATK1', P_SPLDEF='$P_SPLDEF1', P_SPD='$P_SPD1', P_Type='$P_Type1', P_Happiness='$P_Happiness1', P_BattleWins='$P_BattleWins1', P_BattleLosses='$P_BattleLosses1', P_TotalBattles='$P_TotalBattles1', P_EvolutionLevel='$P_EvolutionLevel1', P_EvolveTo='$P_EvolveTo1', P_Move1='$P_Move1_1', P_Move2='$P_Move2_1', P_Move3='$P_Move3_1', P_Move4='$P_Move4_1' WHERE P_ID='$P_ID1' LIMIT 1"); } if($P_HP1 = 0); { echo "You have lost"; header("location: index.php"); } } } } } } //Include Footer File include("bottom.php"); ?> all i did was add mysql_error(); to all your db queries. Quote Link to comment Share on other sites More sharing options...
blueman378 Posted November 26, 2008 Share Posted November 26, 2008 yeah you can see the || thats saying or so if(condition1 OR condition2) Quote Link to comment Share on other sites More sharing options...
Philip Posted November 26, 2008 Share Posted November 26, 2008 yeah you can see the || thats saying or so if(condition1 OR condition2) You can have 2 sets of curly braces without an else clause? I'm 99.9% sure this isn't legit coding: <?php if($var) { echo $var; } { echo $var2; } ?> Quote Link to comment Share on other sites More sharing options...
blueman378 Posted November 26, 2008 Share Posted November 26, 2008 and ill add the other .1%, i didnt acctually read through hiss code so yeah Quote Link to comment Share on other sites More sharing options...
peranha Posted November 26, 2008 Share Posted November 26, 2008 yeah, sorry I wasnt clearer on that, I knew the || meant OR, but I wasnt sure about having 2 curly brackets. Quote Link to comment Share on other sites More sharing options...
sasa Posted November 26, 2008 Share Posted November 26, 2008 ok let see your 1st if condition if (!isset($_COOKIE['UserID'])) { $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); echo "Sorry, you are not logged in. <a href='Login.php'>Login now</a>"; include('bottom.php'); exit; } it say if $_COOKIE NOT exist then $ID = something is it ok? are you setup $ID if $_COOKIE exist? (not read all code) Quote Link to comment Share on other sites More sharing options...
blueman378 Posted November 26, 2008 Share Posted November 26, 2008 acctually it looks like hes saying if the cookie is not set then ID is the cookie... hmm somethings not right there Quote Link to comment Share on other sites More sharing options...
awpti Posted November 26, 2008 Share Posted November 26, 2008 I'd just recommend refactoring this beast. It's frightening. Break it up into common functions and features. Try to stay away from strictly procedural coding as this will lead to painful amounts of repetition in your code. Wasted time on your part (spend coding) and wasted time spent parsing (server side). Sit down with a knowledgeable developer (there are plenty here that willing to offer their insight into problems) and hash this beast out into something that isn't so frightening. Consider looking into a framework (I recommend CodeIgniter) as these sort of force you into good development habits. Or, at least, slant you towards good habits. 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.