Xyphon Posted January 18, 2009 Share Posted January 18, 2009 <?PHP include('top.php'); include('Connect.php'); $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); $Battle_Result= mysql_query("SELECT * FROM Battle_Information WHERE ID='$ID'"); $Battle_Rows= mysql_fetch_array($Battle_Result); $Battle_Result2= mysql_query("SELECT * FROM users WHERE ID='$ID'"); $Battle_Rows2= mysql_fetch_array($Battle_Result2); $Taijutsu= $Battle_Rows2['Taijutsu']; $Taijutsu = mysql_real_escape_string($Taijutsu); $Ninjutsu= $Battle_Rows2['Ninjutsu']; $Ninjutsu = mysql_real_escape_string($Ninjutsu); $Genjutsu= $Battle_Rows2['Genjutsu']; $Genjutsu = mysql_real_escape_string($Genjutsu); $Bloodline1= $Battle_Rows2['Bloodline']; $Bloodline1 = mysql_real_escape_string($Bloodline1); $Bloodline2= $Battle_Rows2['Bloodline2']; $Bloodline2 = mysql_real_escape_string($Bloodline2); $Bloodline3= $Battle_Rows2['Bloodline3']; $Bloodline3 = mysql_real_escape_string($Bloodline3); $Bloodline4= $Battle_Rows2['Bloodline4']; $Bloodline4 = mysql_real_escape_string($Bloodline4); $Bloodline5= $Battle_Rows2['Bloodline5']; $Bloodline5 = mysql_real_escape_string($Bloodline5); $Weapon= $Battle_Rows2['Weapon']; $Weapon = mysql_real_escape_string($Weapon); $Taijutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Taijutsu'"); $Taijutsu_Rows= mysql_fetch_array($Taijutsu_Result); $Ninjutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Ninjutsu'"); $Ninjutsu_Rows= mysql_fetch_array($Ninjutsu_Result); $Genjutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Genjutsu'"); $Genjutsu_Rows= mysql_fetch_array($Genjutsu_Result); $Bloodline1_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline1'"); $Bloodline1_Rows= mysql_fetch_array($Bloodline1_Result); $Bloodline2_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline2'"); $Bloodline2_Rows= mysql_fetch_array($Bloodline2_Result); $Bloodline3_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline3'"); $Bloodline3_Rows= mysql_fetch_array($Bloodline3_Result); $Bloodline4_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline4'"); $Bloodline4_Rows= mysql_fetch_array($Bloodline4_Result); $Bloodline5_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline5'"); $Bloodline5_Rows= mysql_fetch_array($Bloodline5_Result); $Weapon_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Weapon'"); $Weapon_Rows= mysql_fetch_array($Weapon_Result); $Power= $Battle_Rows2['Power']; $Power = mysql_real_escape_string($Power); if(!isset($ID)) { echo "Sorry, you must be logged in to view this page"; include('bottom.php'); exit; } $Submit = $_GET['Type']; if(!$Submit) { if($Battle_Rows['Enemy_Name']=="") { echo "Sorry, you aren't in a battle.."; } else { echo " <html> <center> <table border='3' bordercolor='red' width='550' height='300'><td><center> <table border='0' width='550'><td><center>" . $Battle_Rows['Enemy_Name'] . "<br> HP: " . $Battle_Rows['Enemy_HP'] . "/" . $Battle_Rows['Enemy_Max_HP'] . " Chakra: " . $Battle_Rows['Enemy_Chakra'] . "/" . $Battle_Rows['Enemy_Max_Chakra'] . "</table><br><br><br><br> <table border='0' width='550'><tr><td><center>Taijutsu:<br><a href='battle.php?Type=Taijutsu'>" . $Battle_Rows2['Taijutsu'] . "</a></td> <td>Ninjutsu:<br><a href='battle.php?Type=Ninjutsu'>" . $Battle_Rows2['Ninjutsu'] . "</a></td> <td>Genjutsu:<br><a href='battle.php?Type=Genjutsu'>" . $Battle_Rows2['Genjutsu']. "</a></td> <td>Bloodline:<br><a href='battle.php?Type=Bloodline1'>" . $Battle_Rows2['Bloodline'] . "</a></td> <td>Weapon:<br><a href='battle.php?Type=Weapon'>" . $Battle_Rows2['Weapon'] . "</a></table><br><table border='0' width='550'> <td><center>" . $Battle_Rows2['Username'] . "<br> HP: " . $Battle_Rows2['HP'] . "/" . $Battle_Rows2['Max_HP'] . " Chakra: " . $Battle_Rows2['Chakra'] . "/" . $Battle_Rows2['Max_Chakra'] . "</table></table>"; } } else { if($Submit=='Taijutsu') { $Enemy_HP= $BattleRows['Enemy_HP']; $Damage1= $Taijutsu_Rows['Jutsu_Power']; $Taijutsupower= $Battle_Rows2['$Taijutsu_Power']; $Taijutsupower= mysql_real_escape_string($Taijutsupower); $Damage2= round(($Damage1 + $Taijutsupower) + $Power); $Damage3= round($Damage2 / 5); $Enemy_HP= round($Enemy_HP - $Damage3); echo "<html> <center> <table border='3' bordercolor='red' width='550' height='300'><td><center> <table border='0' width='550'><td><center>" . $Battle_Rows['Enemy_Name'] . "<br> HP: " . $E_HP . "/" . $Battle_Rows['Enemy_Max_HP'] . " Chakra: " . $Battle_Rows['Enemy_Chakra'] . "/" . $Battle_Rows['Enemy_Max_Chakra'] . "</table><br><br><br><br> <table border='0' width='550'><tr><td><center>Taijutsu:<br><a href='battle.php?Type=Taijutsu'>" . $Battle_Rows2['Taijutsu'] . "</a></td> <td>Ninjutsu:<br><a href='battle.php?Type=Ninjutsu'>" . $Battle_Rows2['Ninjutsu'] . "</a></td> <td>Genjutsu:<br><a href='battle.php?Type=Genjutsu'>" . $Battle_Rows2['Genjutsu']. "</a></td> <td>Bloodline:<br><a href='battle.php?Type=Bloodline1'>" . $Battle_Rows2['Bloodline'] . "</a></td> <td>Weapon:<br><a href='battle.php?Type=Weapon'>" . $Battle_Rows2['Weapon'] . "</a></table><br><table border='0' width='550'> <td><center>" . $Battle_Rows2['Username'] . "<br> HP: " . $Battle_Rows2['HP'] . "/" . $Battle_Rows2['Max_HP'] . " Chakra: " . $Battle_Rows2['Chakra'] . "/" . $Battle_Rows2['Max_Chakra'] . "</table><br>You did $Damage3 damage!</table>"; } elseif($Submit=='Ninjutsu') { echo "Ninjutsu!"; } elseif($Submit=='Genjutsu') { echo "Genjutsu!"; elseif($Submit=='Bloodline1') { echo "Bloodline1!"; } else { echo "Weapon!"; } } ?> that is so far of my battle code. The problem is that well after the health bar goes down to 72 or whatever, I'll click the attack button again and it'll stay at 72. I think this is because it refreshes after I click it and then depletes again. Please help me on this.. Quote Link to comment https://forums.phpfreaks.com/topic/141279-solved-help-with-reducing-health/ Share on other sites More sharing options...
Xyphon Posted January 18, 2009 Author Share Posted January 18, 2009 Oops, that was an attempt to fix it heres the real one <?PHP include('top.php'); include('Connect.php'); $ID = $_COOKIE['UserID']; $ID = mysql_real_escape_string($ID); $Battle_Result= mysql_query("SELECT * FROM Battle_Information WHERE ID='$ID'"); $Battle_Rows= mysql_fetch_array($Battle_Result); $Battle_Result2= mysql_query("SELECT * FROM users WHERE ID='$ID'"); $Battle_Rows2= mysql_fetch_array($Battle_Result2); $Enemy_HP= $Battle_Rows['Enemy_HP']; $Taijutsu= $Battle_Rows2['Taijutsu']; $Taijutsu = mysql_real_escape_string($Taijutsu); $Ninjutsu= $Battle_Rows2['Ninjutsu']; $Ninjutsu = mysql_real_escape_string($Ninjutsu); $Genjutsu= $Battle_Rows2['Genjutsu']; $Genjutsu = mysql_real_escape_string($Genjutsu); $Bloodline1= $Battle_Rows2['Bloodline']; $Bloodline1 = mysql_real_escape_string($Bloodline1); $Bloodline2= $Battle_Rows2['Bloodline2']; $Bloodline2 = mysql_real_escape_string($Bloodline2); $Bloodline3= $Battle_Rows2['Bloodline3']; $Bloodline3 = mysql_real_escape_string($Bloodline3); $Bloodline4= $Battle_Rows2['Bloodline4']; $Bloodline4 = mysql_real_escape_string($Bloodline4); $Bloodline5= $Battle_Rows2['Bloodline5']; $Bloodline5 = mysql_real_escape_string($Bloodline5); $Weapon= $Battle_Rows2['Weapon']; $Weapon = mysql_real_escape_string($Weapon); $Taijutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Taijutsu'"); $Taijutsu_Rows= mysql_fetch_array($Taijutsu_Result); $Ninjutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Ninjutsu'"); $Ninjutsu_Rows= mysql_fetch_array($Ninjutsu_Result); $Genjutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Genjutsu'"); $Genjutsu_Rows= mysql_fetch_array($Genjutsu_Result); $Bloodline1_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline1'"); $Bloodline1_Rows= mysql_fetch_array($Bloodline1_Result); $Bloodline2_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline2'"); $Bloodline2_Rows= mysql_fetch_array($Bloodline2_Result); $Bloodline3_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline3'"); $Bloodline3_Rows= mysql_fetch_array($Bloodline3_Result); $Bloodline4_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline4'"); $Bloodline4_Rows= mysql_fetch_array($Bloodline4_Result); $Bloodline5_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline5'"); $Bloodline5_Rows= mysql_fetch_array($Bloodline5_Result); $Weapon_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Weapon'"); $Weapon_Rows= mysql_fetch_array($Weapon_Result); $Power= $Battle_Rows2['Power']; $Power = mysql_real_escape_string($Power); if(!isset($ID)) { echo "Sorry, you must be logged in to view this page"; include('bottom.php'); exit; } $Submit = $_GET['Type']; if(!$Submit) { if($Battle_Rows['Enemy_Name']=="") { echo "Sorry, you aren't in a battle.."; } else { echo " <html> <center> <table border='3' bordercolor='red' width='550' height='300'><td><center> <table border='0' width='550'><td><center>" . $Battle_Rows['Enemy_Name'] . "<br> HP: " . $Battle_Rows['Enemy_HP'] . "/" . $Battle_Rows['Enemy_Max_HP'] . " Chakra: " . $Battle_Rows['Enemy_Chakra'] . "/" . $Battle_Rows['Enemy_Max_Chakra'] . "</table><br><br><br><br> <table border='0' width='550'><tr><td><center>Taijutsu:<br><a href='battle.php?Type=Taijutsu'>" . $Battle_Rows2['Taijutsu'] . "</a></td> <td>Ninjutsu:<br><a href='battle.php?Type=Ninjutsu'>" . $Battle_Rows2['Ninjutsu'] . "</a></td> <td>Genjutsu:<br><a href='battle.php?Type=Genjutsu'>" . $Battle_Rows2['Genjutsu']. "</a></td> <td>Bloodline:<br><a href='battle.php?Type=Bloodline1'>" . $Battle_Rows2['Bloodline'] . "</a></td> <td>Weapon:<br><a href='battle.php?Type=Weapon'>" . $Battle_Rows2['Weapon'] . "</a></table><br><table border='0' width='550'> <td><center>" . $Battle_Rows2['Username'] . "<br> HP: " . $Battle_Rows2['HP'] . "/" . $Battle_Rows2['Max_HP'] . " Chakra: " . $Battle_Rows2['Chakra'] . "/" . $Battle_Rows2['Max_Chakra'] . "</table></table>"; } } else { if($Submit=='Taijutsu') { $Damage1= $Taijutsu_Rows['Jutsu_Power']; $Taijutsupower= $Battle_Rows2['$Taijutsu_Power']; $Taijutsupower= mysql_real_escape_string($Taijutsupower); $Damage2= round(($Damage1 + $Taijutsupower) + $Power); $Damage3= round($Damage2 / 5); $Enemy_HP= round($Enemy_HP - $Damage3); echo "<html> <center> <table border='3' bordercolor='red' width='550' height='300'><td><center> <table border='0' width='550'><td><center>" . $Battle_Rows['Enemy_Name'] . "<br> HP: " . $Enemy_HP . "/" . $Battle_Rows['Enemy_Max_HP'] . " Chakra: " . $Battle_Rows['Enemy_Chakra'] . "/" . $Battle_Rows['Enemy_Max_Chakra'] . "</table><br><br><br><br> <table border='0' width='550'><tr><td><center>Taijutsu:<br><a href='battle.php?Type=Taijutsu'>" . $Battle_Rows2['Taijutsu'] . "</a></td> <td>Ninjutsu:<br><a href='battle.php?Type=Ninjutsu'>" . $Battle_Rows2['Ninjutsu'] . "</a></td> <td>Genjutsu:<br><a href='battle.php?Type=Genjutsu'>" . $Battle_Rows2['Genjutsu']. "</a></td> <td>Bloodline:<br><a href='battle.php?Type=Bloodline1'>" . $Battle_Rows2['Bloodline'] . "</a></td> <td>Weapon:<br><a href='battle.php?Type=Weapon'>" . $Battle_Rows2['Weapon'] . "</a></table><br><table border='0' width='550'> <td><center>" . $Battle_Rows2['Username'] . "<br> HP: " . $Battle_Rows2['HP'] . "/" . $Battle_Rows2['Max_HP'] . " Chakra: " . $Battle_Rows2['Chakra'] . "/" . $Battle_Rows2['Max_Chakra'] . "</table><br>You did $Damage3 damage!</table>"; } elseif($Submit=='Ninjutsu') { echo "Ninjutsu!"; } elseif($Submit=='Genjutsu') { echo "Genjutsu!"; } elseif($Submit=='Bloodline1') { echo "Bloodline1!"; } else { echo "Weapon!"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/141279-solved-help-with-reducing-health/#findComment-739461 Share on other sites More sharing options...
dawsba Posted January 18, 2009 Share Posted January 18, 2009 according to your script you havent defined $E_HP isit declared outside of this script? but just guessing maybe you have mislabeled a var at the top?? Quote Link to comment https://forums.phpfreaks.com/topic/141279-solved-help-with-reducing-health/#findComment-739462 Share on other sites More sharing options...
dawsba Posted January 18, 2009 Share Posted January 18, 2009 lol, ill go and read this one now..........lol Quote Link to comment https://forums.phpfreaks.com/topic/141279-solved-help-with-reducing-health/#findComment-739463 Share on other sites More sharing options...
dawsba Posted January 18, 2009 Share Posted January 18, 2009 in this line: $Taijutsupower= $Battle_Rows2['$Taijutsu_Power']; where is $Taijutsu_Power' and why is it quoted?? Quote Link to comment https://forums.phpfreaks.com/topic/141279-solved-help-with-reducing-health/#findComment-739467 Share on other sites More sharing options...
RussellReal Posted January 18, 2009 Share Posted January 18, 2009 reducing health would be a simple UPDATE however before I get into that.. I want to point something else out that you might not be aware of.. $Taijutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Taijutsu'"); $Taijutsu_Rows= mysql_fetch_array($Taijutsu_Result); $Ninjutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Ninjutsu'"); $Ninjutsu_Rows= mysql_fetch_array($Ninjutsu_Result); $Genjutsu_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Genjutsu'"); $Genjutsu_Rows= mysql_fetch_array($Genjutsu_Result); $Bloodline1_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline1'"); $Bloodline1_Rows= mysql_fetch_array($Bloodline1_Result); $Bloodline2_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline2'"); $Bloodline2_Rows= mysql_fetch_array($Bloodline2_Result); $Bloodline3_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline3'"); $Bloodline3_Rows= mysql_fetch_array($Bloodline3_Result); $Bloodline4_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline4'"); $Bloodline4_Rows= mysql_fetch_array($Bloodline4_Result); $Bloodline5_Result= mysql_query("SELECT * FROM jutsus WHERE Jutsu_Name='$Bloodline5'"); $Bloodline5_Rows= mysql_fetch_array($Bloodline5_Result); could be shortened dramatically.. and save you a ton of performance most likely $result = mysql_query("SELECT * FROM `jutsus` WHERE `Jutsu_Name` IN ('$Taijutsu,$Ninjutsu,$Genjutsu,$Bloodline1,$Bloodline2,$Bloodline3,$Bloodline4,$Bloodline5')"); while ($a = mysql_fetch_array($result)) { $rows[] = $a; } NOW for that update get rid of this line: $Taijutsupower= mysql_real_escape_string($Taijutsupower); $Battle_Rows2['$Taijutsu_Power']; that will look for the literal string '$Taijutsu_Power' not whatever is contained within $Taijutsu_Power if this is really a variable remove the single quotes, if you meant NOT to put the $ in there, remove it and as for the update.. I can't figure out the uhm.. field in the MAIn database for the hp of the user.. so you'd hafta figure out that lil factor.. but your script NEEDS to update the database to tell the database the enemy's new HP value Quote Link to comment https://forums.phpfreaks.com/topic/141279-solved-help-with-reducing-health/#findComment-739469 Share on other sites More sharing options...
Xyphon Posted January 18, 2009 Author Share Posted January 18, 2009 Okay then, I'll make it update the database. Quote Link to comment https://forums.phpfreaks.com/topic/141279-solved-help-with-reducing-health/#findComment-739479 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.