Page 1 of 2

Big code, with open </div> <div style='blah'> ta

Posted: Mon Dec 18, 2006 10:25 pm
by Mythic Fr0st
Subject, not too great eh? what can I say its a large description o_O

ok dont say I haven't tried because i've gone through this code atleast 40 times, i've used HTML editor, PHP editor search and find things, yet I cant seem to get it WORKING, soon as I click the button 'attack' all my

buttons from dex, int, foc, def, last fight, and attack itself all get really large spacing between them, I know what causes it, either having a <div style='position: absolute; top:x; left:x;'> tag that isnt closed with </div> (and it encounters another <div style> tag before being closed, Messing everything up)

Now, I swear theres nothing wrong

I've counted, I have 8 total </div> tags and only 6 </div> tags, but if I remove the last 2 </div> tags it goes WAY off the screen when I click attack

BTW is there any other cause of this problem?

I know probably NO one will help me:/ but I gotta try -.-

btw some <div style> tags can go a while...

this file is included from my main one 'indexg.php'

perhaps it would be best for me to post the actual php docs


<<Problem area below I think>>

Code: Select all

if ($_POST['attack']=='attk') //attk1
{
?>
<div style='Position: absolute; top: 200; left: 325;'>
<?php
if ($phd==false)//phd1
{
?>
<table border='3' width='325'>
<tr>
<td align='center'>

<?php

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);
$result = mysql_query("SELECT * FROM chars");
$row = mysql_fetch_array($result);

$currmonster=$row['currmonster'];

mysql_close($con);
$currmonster=$currmonster+1;
echo '<b>Level '.$currmonster.' '. $mon1[$currmonster-1].'</b><br />';
echo '<b>You attack a '.$mon1[$currmonster-1]. ':</b><br />';
$currmonster=$currmonster-1;


/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////Below is loading monster string and text for dmg and so on
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////













$sa=true;


$mlmon=$currmonster+1;
$strlvlmon=$mlmon * 4;
$strdmgmon=$strlvlmon / 4;
$strdmgmon=rand(0, $strdmgmon * 1.3);
$strdmgmon=round($strdmgmon);

//strength


$dexlvlmon=$mlmon * 5;
$dexcthmon=rand($dexlvlmon - $dexlvl, 100);
//$dexcthmon=$dexcthmon/100;

$_SESSION['lc']=$currlifemon;//$_SESSION['lc']+$currlifemon;

//dexterity
$currlifemon=$mlmon * 13;
$_SESSSION['lc2']=$currmaxlifemon;//$_SESSION['lc2']+$currlifemon;
$currmaxlifemon=$mlmon * 13;
$currlifemon=$_SESSION['lc'];
//life

$deflvlmon=$mlmon * 3;

//defense

$defdamon=$mlmon *  $deflvlmon;
$defdamon=$defdamon/15;

//int

$intlvlmon=$mlmon * 4;
//focus
$foclvlmon=$mlmon * 4;
//mag
$magmon=$mlmon * 9;
$magmaxmon=$mlmon * 9;

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);

{mysql_query("UPDATE chars SET currmonster = $currmonster
");}
mysql_close($con);

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

{mysql_query("UPDATE m_l SET currlifemon = $currmaxlifemon
");}

mysql_query("UPDATE chars SET mlmon = $mlmon
");

mysql_query("UPDATE chars SET strlvlmon = $strlvlmon
");

mysql_query("UPDATE chars SET strdmgmon = $strdmgmon
");

mysql_query("UPDATE chars SET dexlvlmon = $dexlvlmon
");

mysql_query("UPDATE chars SET dexcthmon = $dexcthmon
");

mysql_query("UPDATE chars SET currlifemon = $currlifemon
");


mysql_query("UPDATE chars SET currmaxlifemon = $currmaxlifemon
");


mysql_query("UPDATE chars SET deflvlmon = $deflvlmon
");

mysql_query("UPDATE chars SET defdamon = $defdamon
");


mysql_query("UPDATE chars SET intlvlmon = $intlvlmon
");


mysql_query("UPDATE chars SET foclvlmon = $foclvlmon
");


mysql_query("UPDATE chars SET magmon = $magmon
");

mysql_query("UPDATE chars SET magmaxmon = $magmaxmon
");



mysql_query("UPDATE chars SET currlife = $currlife
");




/*
echo $br;
echo $dexcthmon.' dexcthmon';
echo $br;
echo $dexcth.' dexcth';
echo $br;
echo $mlmon.'ML';
echo $br;
echo $dexlvlmon.'dex';
echo $br;
echo $strlvlmon.'str';
echo $br;
echo $deflvlmon.'def';
echo $br;
echo $intlvlmon.'int';
echo $br;
echo $foclvlmon.'foc';
echo $br;

*/













if ($dexcth > $dexcthmon)
{
echo "You attack with your ".$weapon." and hit for ".$strdmg." damage";
$currlifemon=$currlifemon-$strdmg;
}
else 
{
echo "You attack with your ".$weapon." and you miss"; $strdmg=0;
}
echo '<br /> Current Life is '.$currlifemon. '<br />';

if ($dexcthmon > $dexcth)
{ //a4
echo '<b>'.$mon1[$currmonster]. "</b> attacks you and hits you for ".$strdmgmon; //later add .dmg
$currlife=$currlife-$strdmgmon;

}
else 
{
echo '<b>'.$mon1[$currmonster]. "</b> attacks you and misses"; $strdmgmon=0;
}
}
?>

</td>
</tr>
</table>

</font>
<?php

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////Levels and XP below////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
if ($phd==false)//phd 12
{

// damage delt (to increase XP) below MUST stay at bottom
if ($tstr==true)
{
$strxp=$strxp+$strdmg;
}

if ($tdex==true)
{
$dexxp=$dexxp+$strdmg;
}

if ($tdef==true)
{
$defxp=$defxp+$strdmg;
}
if ($tint==true)
{
$intxp=$intxp+$strdmg;
}
if ($tfoc==true)
{
$focxp=$focxp+$strdmg;
}
// damage delt (to increase XP) above MUST STAY huh
//XP check below
if ($strxp>=$strlvl * $strdiv * $strlvl)
{
$strlvl=$strlvl+1;
$strdiv=$strdiv+1;
}
if ($dexxp>=$dexlvl * $dexdiv * $dexlvl)
{
$dexlvl=$dexlvl+1;
$dexdiv=$dexdiv+1;
}
if ($defxp>=$deflvl * $defdiv * $deflvl)
{
$deflvl=$deflvl+1;
$defdiv=$defdiv+1;
}

if ($intxp>=$intlvl * $intdiv * $intlvl)
{
$intlvl=$intlvl+1;
$intdiv=$intdiv+1;
}
if ($focxp>=$foclvl * $focdiv * $foclvl)
{
$foclvl=$foclvl+1;
$focdiv=$focdiv+1;
}

}//attk2 // I think it may be PHD2 //phd13 I think
if ($currlife < 1)
{
?>
</div>
<DIV STYLE='Position: absolute; Top: 200; Left: 325;'>
<?php
echo '<table border=\'3\' width=\'325\'> <tr> <td align="center"><b><font color=\'maroon\'>You are dead</font></b></td></tr></table>';
$phd=true;
?>
</div>
<?php
}//currlife from just above
?>
</div><!--///////////////////////////////////POSSIBLE BADDY (6)</div>-->
<?php
}//attk4
?><!--/////////////////////////////////////POSSIBLE BADDY (7) </div> they seem to be work 6,7-->
large eh? if I remove baddy (6) or (7) but leave one of them, it stays how it currently is (which is bad), but if I remove both it MESSES up badly

I've gone through my code, line by line, slowly, hoping, yet I cant seem to find the problem...

I no for fact no one will go through this but o well

heres the 1307 line code o_O woo

Code: Select all

<html>
<body>
<head>
<STYLE TYPE="text/css">
<!--
A {text-decoration:none}
-->
</STYLE>
<style type='text/css'>
body
{
background-image:
url('SilverBG.jpg')
}
</style>
</head>
<?php

if (isset($_SESSION['islogged']))//islogged3
{
if ($_SESSION['islogged']==true)//islogged1
{


$id=$_SESSION['id'];
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);
$result = mysql_query("SELECT * FROM chars 
 WHERE idcount = $id");


$row = mysql_fetch_array($result);

$inv=$row['inv'];
$inv=unserialize($inv);
$invmax=50;
mysql_close($con);
$equipment=false;
$_SESSION['lc']=0;
$_SESSION['lc2']=0;
$_SESSION['cm']=0;
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

$result = mysql_query("SELECT * FROM m_l");
$row = mysql_fetch_array($result);

$mlmon=$row['mlvl'];
$strlvlmon=$row['strlvlmon'];
$strdmgmon=$strlvlmon / 4;
$strdmgmon=rand(0, $strdmgmon * 1.3);
$strdmgmon=round($strdmgmon);
//strength
mysql_close($con);

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);
$result = mysql_query("SELECT * FROM chars WHERE idcount = $id");
$row = mysql_fetch_array($result);



$dexlvl=$row['dexlvl'];
mysql_close($con);
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

$result = mysql_query("SELECT * FROM m_l"); //monster
$row = mysql_fetch_array($result);

$dexlvlmon=$row['dexlvlmon'];
$dexcthmon=rand($dexlvlmon - $dexlvl, 100);
$dexcthmon=$dexcthmon/100;

//dexterity

$currlifemon=$row['currlifemon'];
$currmaxlifemon=$row['currmaxlifemon'];
//life

$deflvlmon=$row['deflvlmon'];

//defense

$defdamon=$mlmon *  $deflvlmon;
$defdamon=$defdamon/100;

//int

$intlvlmon=$row['intlvlmon'];
//focus
$foclvlmon=$row['foclvlmon'];
//mag
$magmon=$row['magmon'];
$mhs=$row['mhs'];
//userstuff
mysql_close($con);



$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);
$result = mysql_query("SELECT * FROM chars WHERE idcount = $id");
$row = mysql_fetch_array($result);
$ml=$row['mlvl'];
$strlvl=$row['strlvl'];
$strdmg=$strlvl/4;
$strdmg=rand(0, $strdmg * 1.3);
$strdmg=round($strdmg);
$strxp=$row['strxp'];
$strdiv=$row['strdiv'];
//str
$dexlvl=$row['dexlvl'];
$dexxp=$row['dexxp'];
$dexcth=rand($ml, $dexlvl * 10);
$dexcth=$dexcth/100;
$dexdiv=$row['dexdiv'];
//dex
$deflvl=$row['deflvl'];
$defxp=$row['defxp'];
$defda=$ml * $deflvl;
$defda=$defda/100;
$defdiv=$row['defdiv'];
//def
$currlife=$row['currlife'];
$maxlife=$row['maxlife'];
//life
$gold=$row['gold'];
$intlvl=$row['intlvl'];
$intxp=$row['intxp'];
$foclvl=$row['foclvl'];
$focxp=$row['focxp'];
$mag=$row['mag'];
$intdiv=$row['intdiv'];
$focdiv=$row['focdiv'];
$bank=$row['bankedgold'];
$magmax=$row['magmax'];
//other
$tdex=$row['tdex'];
$tstr=$row['tstr'];
$tdef=$row['tdef'];
$tint=$row['tint'];
$tfoc=$row['tfoc'];
$phd=$row['phd'];
$sa=$row['sa'];
$currmonster='0';
$sa=$row['sa'];
$lastfight=$row['lastfight'];
$helm=$row['helm'];
$bp=$row['bp'];
$lp=$row['lp'];
$shield=$row['shield'];
$weapon=$row['weapon'];
$weapontype=$row['weapontype'];
$spell=$row['spell'];
$spelltype=$row['spelltype'];
$boots=$row['boots'];
$amulet=$row['amulet'];
$ring=$row['ring'];
$misc=$row['misc'];
$wdmg=$row['wdmg'];
$vert=$row['vert'];
$horz=$row['horz'];
$currtown=$row['currtown'];
$wdmg=$row['wdmg'];
$weaponprices=array(36, 86, 201);
$weapondmg=array(0.5, 1.75, 3);
$spellprices=array(36,86,201);
$spelldmg=array(0.5, 1.75, 3);
$weaponlist = array('Iron Dagger'=>true, 'Iron Sword'=>false, 'Steel Sword'=>false, 'Titan Sword' => false);
$spelllist=array('Ignite');
$armorlist=array('Iron Breast Plate'); ////////////////////TRY and have a 3 dimension-4 dimension
$leglist=array('Iron Leg Plates'); ///////////////////////array holding damage aswell and price
$helmlist=array('Iron Full Helm');
$bootlist=array('Iron Boots');
$gauntletlist=array('Iron Gauntlets');
/////////////////////////////////////////////CLEAR ABOVE
if (isset($_POST['eq1']))
 {
  if ($_POST['eq1']=='eq2')
   {
     if (isset($_POST['inv']))
      {
       $x=$_POST['inv'];
       foreach ($weaponlist as $is => $q)
         {
           if ($is == $inv[$x])
                        {
            if ($weaponlist[$q]==true)
             {
              $weaponlist[$x]=false;
              $wdmg=$weapondmg[$x];
              $weapon=$is;
              echo 'set';
              }
              else
              {
              $weaponlist[$q]=true;
              $wdmg=0;
              $weapon='Fists';
              echo 'unset <br />';
               }
            }
         }
      }
   }
 }




$br="<br />";

//may have to change phd later
if (!isset($phd))
{
$phd=false;
}

if(isset($_POST['strBTN']))
{
if($_POST['strBTN'] == 'Str')
{
        $tstr = true;
        $tdex = false;
        $tdef = false;
        $tint = false;
        $tfoc = false;
}
}
if(isset($_POST['dexBTN']))
{
if($_POST['dexBTN'] == 'Dex')
{
        $tstr = false;
        $tdex = true;
        $tdef = false;
        $tint = false;
        $tfoc = false;
}
}
if(isset($_POST['defBTN']))
{
if($_POST['defBTN'] == 'Def')
{
        $tstr = false;
        $tdex = false;
        $tdef = true;
        $tint = false;
        $tfoc = false;
}
}
if(isset($_POST['intBTN']))
{
if($_POST['intBTN'] == 'Int')
{
        $tstr = false;
        $tdex = false;
        $tdef = false;
        $tint = true;
        $tfoc = false;
}
}

if(isset($_POST['focBTN']))
{
if($_POST['focBTN'] == 'Foc')
{
        $tstr = false;
        $tdex = false;
        $tdef = false;
        $tint = false;
        $tfoc = true;//possibly add if ($equipment==true) $equipment == true)
}
}



if (isset($_POST['ceq1']))
{
if ($_POST['ceq1']=='ceq2')
{
$equipment=true;
}
}

if (isset($_POST['ceq3']))
{
if ($_POST['ceq3']=='ceq4')
{
$equipment=false;
}
}


////////////////////////////////////////////////////CLEAR ABOVE from the </div> problem


$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);


$mon1 = array('Baby Elf', 'Wood Elf', 'Dark Elf', 'Blood Elf');
mysql_close($con);

if (isset($_POST['lc1']))
{
if ($_POST['lc1']=='lc2')
{
?>
<DIV STYLE='Position: absolute; Top: 200; Left: 325;'>
<?php
$_SESSION['lc']=0;
$_SESSION['lc2']=0;
$currmonster=$lastfight;
$currmonster=$currmonster+1;
echo '<table border=\'3\' width="325"> <tr> <td align=\'center\'><b>Level '.$currmonster.' '.$mon1[$currmonster-1].'</b><br />';
echo '<b>You challenge a '.$mon1[$currmonster-1].'</b></td></tr></table>';
$currmonster=$currmonster-1;
$currlifemon=$currmaxlifemon;









$sa=true;
$_SESSION['lc']=0;
$_SESSION['lc2']=0;


$mlmon=$currmonster+1;
$strlvlmon=$mlmon * 4;
$strdmgmon=$strlvlmon / 4;
$strdmgmon=rand(0, $strdmgmon * 1.3);
$strdmgmon=round($strdmgmon);

//strength


$dexlvlmon=$mlmon * 7;
$dexcthmon=rand($dexlvlmon - $dexlvl, 100);
$dexcthmon=$dexcthmon/100;

//dexterity

$currlifemon=$mlmon * 9;
$currmaxlifemon=$mlmon * 9;
//life

$deflvlmon=$mlmon * 5;

//defense

$defdamon=$mlmon *  $deflvlmon;
$defdamon=$defdamon/100;

//int

$intlvlmon=$mlmon * 7;
//focus
$foclvlmon=$mlmon * 7;
//mag
$magmon=$mlmon * 9;
$magmaxmon=$mlmon * 9;

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);

{mysql_query("UPDATE chars SET currmonster = $currmonster
");}
mysql_close($con);

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

{mysql_query("UPDATE m_l SET currlifemon = $currmaxlifemon
");}

mysql_query("UPDATE chars SET mlmon = $mlmon
");

mysql_query("UPDATE chars SET strlvlmon = $strlvlmon
");

mysql_query("UPDATE chars SET strdmgmon = $strdmgmon
");

mysql_query("UPDATE chars SET dexlvlmon = $dexlvlmon
");

mysql_query("UPDATE chars SET dexcthmon = $dexcthmon
");

mysql_query("UPDATE chars SET currlifemon = $currlifemon
");


mysql_query("UPDATE chars SET currmaxlifemon = $currmaxlifemon
");


mysql_query("UPDATE chars SET deflvlmon = $deflvlmon
");

mysql_query("UPDATE chars SET defdamon = $defdamon
");


mysql_query("UPDATE chars SET intlvlmon = $intlvlmon
");


mysql_query("UPDATE chars SET foclvlmon = $foclvlmon
");


mysql_query("UPDATE chars SET magmon = $magmon
");

mysql_query("UPDATE chars SET magmaxmon = $magmaxmon
");

?>
</div>
<?php

}
}


///////

//locations


//locations

if (isset($_POST['nf']))
{ //a1
if ($_POST['nf'] == 'nf2')
{
if ($phd==false)
{
?>
<DIV STYLE='Position: absolute; Top: 200; Left: 325;'><!--325-->
<?php

// may have to remove the BIG stat text
$currmonster=$_POST['monsters'];
$currlifemon=$currmaxlifemon;
$sa=true;
$_SESSION['lc']=0;
$_SESSION['lc2']=0;


$mlmon=$currmonster+1;
$strlvlmon=$mlmon * 4;
$strdmgmon=$strlvlmon / 4;
$strdmgmon=rand(0, $strdmgmon * 1.3);
$strdmgmon=round($strdmgmon);

//strength


$dexlvlmon=$mlmon * 7;
$dexcthmon=rand($dexlvlmon - $dexlvl, 100);
$dexcthmon=$dexcthmon/100;

//dexterity

$currlifemon=$mlmon * 9;
$currmaxlifemon=$mlmon * 9;
//life

$deflvlmon=$mlmon * 5;

//defense

$defdamon=$mlmon *  $deflvlmon;
$defdamon=$defdamon/100;

//int

$intlvlmon=$mlmon * 7;
//focus
$foclvlmon=$mlmon * 7;
//mag
$magmon=$mlmon * 9;
$magmaxmon=$mlmon * 9;

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);

{mysql_query("UPDATE chars SET currmonster = $currmonster
");}
mysql_close($con);

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

{mysql_query("UPDATE m_l SET currlifemon = $currmaxlifemon
");}

mysql_query("UPDATE chars SET mlmon = $mlmon
");

mysql_query("UPDATE chars SET strlvlmon = $strlvlmon
");

mysql_query("UPDATE chars SET strdmgmon = $strdmgmon
");

mysql_query("UPDATE chars SET dexlvlmon = $dexlvlmon
");

mysql_query("UPDATE chars SET dexcthmon = $dexcthmon
");

mysql_query("UPDATE chars SET currlifemon = $currlifemon
");


mysql_query("UPDATE chars SET currmaxlifemon = $currmaxlifemon
");


mysql_query("UPDATE chars SET deflvlmon = $deflvlmon
");

mysql_query("UPDATE chars SET defdamon = $defdamon
");


mysql_query("UPDATE chars SET intlvlmon = $intlvlmon
");


mysql_query("UPDATE chars SET foclvlmon = $foclvlmon
");


mysql_query("UPDATE chars SET magmon = $magmon
");

mysql_query("UPDATE chars SET magmaxmon = $magmaxmon
");



mysql_query("UPDATE chars SET currlife = $currlife
");
$currmonster=$currmonster+1;
echo '<table border=\'3\' width="325"> <tr> <td align=\'center\'><b>Level '.$currmonster.' '.$mon1[$currmonster-1].'</b><br />';
echo '<b>You challenge a '.$mon1[$currmonster-1].'</b></td></tr></table>';
mysql_close($con);
$currmonster=$currmonster-1;
$lastfight=$currmonster;
?>
</div>
<?php
}
}
}

$br='<br />';
//damage goes here
$strdmg=$strlvl / 4;
//damage goes above
//deal dmg below
$strdmg=rand(0, $strdmg * 1.1);
$strdmg=round($strdmg);
$strdmg=$strdmg+$wdmg;
//ar (armor reduction), //hr helm reduction, //bpr (r = reduction) //lpr, //shieldR, //bootr
//amuletb(bonus) //ringb(bonus)

$defdamon=$mlmon * $deflvlmon;
$defdamon=$defdamon/15;
//$strdmg=$strdmg-$defdamon;
//$strdmg=round($_SESSION['strdmg']);
//monster stuff below

$strdmgmon=$strlvlmon / 4;
//damage goes above
//deal dmg below
$strdmgmon=rand(0, $strdmgmon * 1.1);
$strdmgmon=round($strdmgmon);

$defda=$ml * $deflvl;
$defda=$defda/15;
$strdmgmon=$strdmgmon-$defda; //later add the if ($strdmgmon < 0) set $strdmgmon =0; so we dont get minus dmg
$strdmgmon=round($strdmgmon);
if ($strdmgmon <= 0)
{
$strdmgmon=0;
}

//monster stuff

$dexcth=rand($deflvl - $deflvlmon, 100);
$dexcthmon=rand($deflvlmon - $deflvl, 100);
//damage above
//$dexcth=$dexcth/100;
//$dexptm=$dexptm/100;

$dropgold=$mlmon;
$dropgold=rand($dropgold, $dropgold * 2.3);
$dropgold=round($dropgold);

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

mysql_query("UPDATE m_l SET currlifemon = $currlifemon
");
mysql_query("UPDATE m_l SET dexcthmon = $dexcthmon
");

mysql_close($con);
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);

mysql_query("UPDATE chars SET dexcth = $dexcth
");
mysql_close($con);

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////Check to see if you've clicked attk button below////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

if ($currlife < 1)
{ $gold=0;
$phd=true;
}

//dealdmg above
echo $br;
?>
<font color='darkblue' size='3'>
<?php
if (isset($_POST['attack'])) //attk3
{

if ($currlifemon < 1)
{
?>
<div style='Position: absolute; top: 200; left: 325;'><!--325-->
<?php
echo '<table border=\'3\' width="325"> <tr> <td align="center"><b>The monster is dead</b></td> </tr> </table>'; 
$mhs=true;
?>
</div>
<?php
}

if ($currlifemon >= 1)//currlifemon1
{

//a2
if ($_POST['attack']=='attk') //attk1
{
?>
<div style='Position: absolute; top: 200; left: 325;'>
<?php
if ($phd==false)//phd1
{
?>
<table border='3' width='325'>
<tr>
<td align='center'>

<?php

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);
$result = mysql_query("SELECT * FROM chars");
$row = mysql_fetch_array($result);

$currmonster=$row['currmonster'];

mysql_close($con);
$currmonster=$currmonster+1;
echo '<b>Level '.$currmonster.' '. $mon1[$currmonster-1].'</b><br />';
echo '<b>You attack a '.$mon1[$currmonster-1]. ':</b><br />';
$currmonster=$currmonster-1;


/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////Below is loading monster string and text for dmg and so on
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////













$sa=true;


$mlmon=$currmonster+1;
$strlvlmon=$mlmon * 4;
$strdmgmon=$strlvlmon / 4;
$strdmgmon=rand(0, $strdmgmon * 1.3);
$strdmgmon=round($strdmgmon);

//strength


$dexlvlmon=$mlmon * 5;
$dexcthmon=rand($dexlvlmon - $dexlvl, 100);
//$dexcthmon=$dexcthmon/100;

$_SESSION['lc']=$currlifemon;//$_SESSION['lc']+$currlifemon;

//dexterity
$currlifemon=$mlmon * 13;
$_SESSSION['lc2']=$currmaxlifemon;//$_SESSION['lc2']+$currlifemon;
$currmaxlifemon=$mlmon * 13;
$currlifemon=$_SESSION['lc'];
//life

$deflvlmon=$mlmon * 3;

//defense

$defdamon=$mlmon *  $deflvlmon;
$defdamon=$defdamon/15;

//int

$intlvlmon=$mlmon * 4;
//focus
$foclvlmon=$mlmon * 4;
//mag
$magmon=$mlmon * 9;
$magmaxmon=$mlmon * 9;

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);

{mysql_query("UPDATE chars SET currmonster = $currmonster
");}
mysql_close($con);

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

{mysql_query("UPDATE m_l SET currlifemon = $currmaxlifemon
");}

mysql_query("UPDATE chars SET mlmon = $mlmon
");

mysql_query("UPDATE chars SET strlvlmon = $strlvlmon
");

mysql_query("UPDATE chars SET strdmgmon = $strdmgmon
");

mysql_query("UPDATE chars SET dexlvlmon = $dexlvlmon
");

mysql_query("UPDATE chars SET dexcthmon = $dexcthmon
");

mysql_query("UPDATE chars SET currlifemon = $currlifemon
");


mysql_query("UPDATE chars SET currmaxlifemon = $currmaxlifemon
");


mysql_query("UPDATE chars SET deflvlmon = $deflvlmon
");

mysql_query("UPDATE chars SET defdamon = $defdamon
");


mysql_query("UPDATE chars SET intlvlmon = $intlvlmon
");


mysql_query("UPDATE chars SET foclvlmon = $foclvlmon
");


mysql_query("UPDATE chars SET magmon = $magmon
");

mysql_query("UPDATE chars SET magmaxmon = $magmaxmon
");



mysql_query("UPDATE chars SET currlife = $currlife
");




/*
echo $br;
echo $dexcthmon.' dexcthmon';
echo $br;
echo $dexcth.' dexcth';
echo $br;
echo $mlmon.'ML';
echo $br;
echo $dexlvlmon.'dex';
echo $br;
echo $strlvlmon.'str';
echo $br;
echo $deflvlmon.'def';
echo $br;
echo $intlvlmon.'int';
echo $br;
echo $foclvlmon.'foc';
echo $br;

*/













if ($dexcth > $dexcthmon)
{
echo "You attack with your ".$weapon." and hit for ".$strdmg." damage";
$currlifemon=$currlifemon-$strdmg;
}
else 
{
echo "You attack with your ".$weapon." and you miss"; $strdmg=0;
}
echo '<br /> Current Life is '.$currlifemon. '<br />';

if ($dexcthmon > $dexcth)
{ //a4
echo '<b>'.$mon1[$currmonster]. "</b> attacks you and hits you for ".$strdmgmon; //later add .dmg
$currlife=$currlife-$strdmgmon;

}
else 
{
echo '<b>'.$mon1[$currmonster]. "</b> attacks you and misses"; $strdmgmon=0;
}
}
?>

</td>
</tr>
</table>

</font>
<?php

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////Levels and XP below////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
if ($phd==false)//phd 12
{

// damage delt (to increase XP) below MUST stay at bottom
if ($tstr==true)
{
$strxp=$strxp+$strdmg;
}

if ($tdex==true)
{
$dexxp=$dexxp+$strdmg;
}

if ($tdef==true)
{
$defxp=$defxp+$strdmg;
}
if ($tint==true)
{
$intxp=$intxp+$strdmg;
}
if ($tfoc==true)
{
$focxp=$focxp+$strdmg;
}
// damage delt (to increase XP) above MUST STAY huh
//XP check below
if ($strxp>=$strlvl * $strdiv * $strlvl)
{
$strlvl=$strlvl+1;
$strdiv=$strdiv+1;
}
if ($dexxp>=$dexlvl * $dexdiv * $dexlvl)
{
$dexlvl=$dexlvl+1;
$dexdiv=$dexdiv+1;
}
if ($defxp>=$deflvl * $defdiv * $deflvl)
{
$deflvl=$deflvl+1;
$defdiv=$defdiv+1;
}

if ($intxp>=$intlvl * $intdiv * $intlvl)
{
$intlvl=$intlvl+1;
$intdiv=$intdiv+1;
}
if ($focxp>=$foclvl * $focdiv * $foclvl)
{
$foclvl=$foclvl+1;
$focdiv=$focdiv+1;
}

}//attk2 // I think it may be PHD2 //phd13 I think
if ($currlife < 1)
{
?>
</div>
<DIV STYLE='Position: absolute; Top: 200; Left: 325;'>
<?php
echo '<table border=\'3\' width=\'325\'> <tr> <td align="center"><b><font color=\'maroon\'>You are dead</font></b></td></tr></table>';
$phd=true;
?>
</div>
<?php
}//currlife from just above
?>
</div><!--///////////////////////////////////POSSIBLE BADDY (6)</div>-->
<?php
}//attk4
?><!--/////////////////////////////////////POSSIBLE BADDY (7) </div> they seem to work 6,7-->
<?php
if ($currlifemon < 1)
{
$mhs=true;
$curlifemon=0;
}


if ($mhs==true)
{ //a3
$gold=$gold+$dropgold; 
$mhs=false;
$_SESSION['lc']=0;
$_SESSION['lc2']=0;
}
}//currlifemon2
}
// STAT INCREASING ABOVE, Must be huh
//XP check above//
?>
<?php
//movement system
//////////////////////////////////////////////////////////BREAK
$f='</font>';
$d='</div>';
//equipment and such
///////////////////////////////////////Displays Stat Bars/////////////////////////////////////////
////////////////Increases main level//////////
if ($strlvl + $dexlvl + $deflvl + $intlvl + $foclvl - 25 >=$ml * 15)
{
$ml=$ml+1;
$maxlife=$maxlife+$strlvl/2 + $ml;
$magmax=$magmax+$intlvl/2 + $ml;//may not use magic later on
$currlife=$maxlife;
$mag=$magmax; //or maxmag
}
/////////////Increases main level////////////

/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////Below/is/Forms/buttons/and/so/on//////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("chars", $con);

mysql_query("UPDATE chars SET gold = $gold
");

mysql_query("UPDATE chars SET bankedgold = $bank
");

mysql_query("UPDATE chars SET strxp = $strxp
");

mysql_query("UPDATE chars SET dexxp = $dexxp
");

mysql_query("UPDATE chars SET defxp = $defxp
");

mysql_query("UPDATE chars SET currlife = $currlife
");

mysql_query("UPDATE chars SET maxlife = $maxlife
");
mysql_query("UPDATE chars SET strlvl = $strlvl
");

mysql_query("UPDATE chars SET deflvl = $deflvl
");

mysql_query("UPDATE chars SET dexlvl = $dexlvl
");

//mysql_query("UPDATE chars SET sa = $sa //unneeded?
//");
if ($phd==true)
{mysql_query("UPDATE chars SET phd = 1
");}
else
{mysql_query("UPDATE chars SET phd = 0
");}
if ($tdex==true)
{mysql_query("UPDATE chars SET tdex = 1
");}
else
{mysql_query("UPDATE chars SET tdex = 0
");}

if ($tstr==true)
{mysql_query("UPDATE chars SET tstr = 1
");}
else
{mysql_query("UPDATE chars SET tstr = 0
");}

if ($tdef==true)
{mysql_query("UPDATE chars SET tdef = 1
");}
else
{mysql_query("UPDATE chars SET tdef = 0
");}

mysql_query("UPDATE chars SET mlvl = $ml
");

if ($tint==true)
{mysql_query("UPDATE chars SET tint = 1
");}
else
{mysql_query("UPDATE chars SET tint = 0
");}

if ($tfoc==true)
{mysql_query("UPDATE chars SET tfoc = 1
");}
else
{mysql_query("UPDATE chars SET tfoc = 0
");}

mysql_query("UPDATE chars SET mlvl = $ml
");

mysql_query("UPDATE chars SET dexdiv = $dexdiv
");

mysql_query("UPDATE chars SET strdiv = $strdiv
");

mysql_query("UPDATE chars SET defdiv = $defdiv
");

mysql_query("UPDATE chars SET magmax = $magmax
");

mysql_query("UPDATE chars SET intdiv = $intdiv
");

mysql_query("UPDATE chars SET focdiv = $focdiv
");

mysql_query("UPDATE chars SET intlvl = $intlvl
");

mysql_query("UPDATE chars SET foclvl = $foclvl
");

mysql_query("UPDATE chars SET intxp = $intxp
");

mysql_query("UPDATE chars SET focxp = $focxp
");

mysql_query("UPDATE chars SET lastfight = $lastfight
");


mysql_query("UPDATE chars SET vert = $vert
");

mysql_query("UPDATE chars SET horz = $horz
");
$inv=serialize($inv);
mysql_query("UPDATE chars SET inv = $inv
");
mysql_query("UPDATE chars SET wdmg = $wdmg
");

mysql_close($con);


$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("weapons", $con);


mysql_close($con);
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

mysql_query("UPDATE m_l SET currlifemon = $currlifemon
");

if ($mhs==false)
{
mysql_query("UPDATE chars SET mhs = 0
");
}
else
{
mysql_query("UPDATE chars SET mhs = 1
");
}
} //islogged2
}//islogged4
else
{
?>
<DIV STYLE='Position: absolute; Top: 250; Left: 380;'>
<?php
echo '<table border=\'3\'><tr><td><b><font size="5">You are not logged in</font></b></td></tr><tr><td align="center"> Please click below to login<br /><form action="home.php" method="post"><input type=\'submit\' value="Login"></form></td></tr></table>';
?>
</div>
<?php
}
?>
<!-- NOTES, later on load the monsters to array, and load the dmg str ALL of it, into an array stat variable matching the monster array and use that for monsters-->
</body>

</html>
oh Lord God help me lolz

Posted: Mon Dec 18, 2006 11:02 pm
by John Cartwright
I know probably NO one will help me:/ but I gotta try -.-
Unfortunantly this is probably the case, considering there is a ton of source code to sift through. What I can recommend is you get an editor with source folding so you can hide the php code and only look at the html. From there, it should be a lot easier to identify where your mis matched tags are.

I don't know exactly which IDE's have source folding, although I know macromedia does (whom offer a a free trial).. it may help to check out our favorite editor thread in the general discussion forum.

You never know though, we do have some very generous member that may infact take the time out of their precious days but I wouldn't hold my breathe.

Either way, sorry I couldn't be of more help, but it's not fair to the rest of the users if I spend so long trying to help a single person. Good luck.

Posted: Mon Dec 18, 2006 11:26 pm
by feyd
The only thing that caught my eye as I paged down is lots of UPDATE queries that could be consolidated.

Eclipse has source folding, for anyone that cares.

hmm

Posted: Tue Dec 19, 2006 12:46 am
by Mythic Fr0st
So far I've found 3 different eclipse editors, none work or are for PHP

Got a link? or specific name? company name?

Posted: Tue Dec 19, 2006 12:50 am
by John Cartwright
you need to install the PHP plugin.

Posted: Tue Dec 19, 2006 12:59 am
by Mythic Fr0st
hmm ok I think I found it,

is the editor like eclipse-SDK-3.2.1-win32.zip (120megabyte)

and the plugin at



http://sourceforge.net/projects/phpeclipse/

is that correct? install plugin into the editors directory?


uhuhh this is a java editor? and um how do I select only html stuff?

Posted: Tue Dec 19, 2006 7:49 am
by feyd
Once you're sure phpEclipse is installed correctly, Window > Open Perspective > Other... Select PHP. You will need to turn on folding if you want it. That is located in Window > Preferences. Expand the PHP stub and then its Editor stub. Select Folding. Ensure that "Enable Folding" is highlighted. If you do not check any of the other boxes folding by itself won't do a thing.

m

Posted: Tue Dec 19, 2006 4:34 pm
by Mythic Fr0st
There was a php stub inside another stub, but no editor, the only places that there is 'folding' is

ant/folding which says

initially folder these region types
DTD blocks
Comments
defining tasks
targets
------------------------
then the other is in

java/editor/folding and says

enable folding
comments
header comments
inner types
members
imports

and thats all, not sure why, I still dont get how to do it, I've tried right clicking on the page, - source and fiddling with stuff in there, i've gone to that perspective thing, that didnt work either :/

O well thanks for trying, i'll keep fiddling around

Posted: Tue Dec 19, 2006 4:47 pm
by feyd
If you didn't find the php stub then then installation of it probably didn't go through correctly. When I install it I unpack the phpeclipse zip to a separate directory and navigate Eclipse's install/updater to the directory.

Posted: Tue Dec 19, 2006 6:00 pm
by RobertGonzalez
Search google for PHPEclipse. When you get to their website, look at their wiki. The wiki has very detailed, easy-to-follow steps on how to download and install Eclipse and how to easily setup the PHPEclipse plugin. Seriously, it will take all of ten minutes to get it working like a dream.

As for your code, <div> tags are more of a client side issue. How is the rendering of your page related to the your PHP code?

And a couple of suggestions on your code... open your database server connection once, do what you have to do, then close it once. The way your code is working right now is that you are opening a connection, running a query, closing the connection, then opening it, yadda yadda. If you site ever gets a lot of traffic, your users could find themselves with half loaded pages because of server connection issues midway through a page load.

Also, your update queries that look like this:

Code: Select all

mysql_query("UPDATE chars SET mlmon = $mlmon
");

mysql_query("UPDATE chars SET strlvlmon = $strlvlmon
");

mysql_query("UPDATE chars SET strdmgmon = $strdmgmon
");

mysql_query("UPDATE chars SET dexlvlmon = $dexlvlmon
");

mysql_query("UPDATE chars SET dexcthmon = $dexcthmon
");

mysql_query("UPDATE chars SET currlifemon = $currlifemon
");


mysql_query("UPDATE chars SET currmaxlifemon = $currmaxlifemon
");


mysql_query("UPDATE chars SET deflvlmon = $deflvlmon
");

mysql_query("UPDATE chars SET defdamon = $defdamon
");


mysql_query("UPDATE chars SET intlvlmon = $intlvlmon
");


mysql_query("UPDATE chars SET foclvlmon = $foclvlmon
");


mysql_query("UPDATE chars SET magmon = $magmon
");

mysql_query("UPDATE chars SET magmaxmon = $magmaxmon
");



mysql_query("UPDATE chars SET currlife = $currlife
");
can all be pushed into one query that looks like this (although I would seriously suggest a where clause in there... unless you want to edit every record in the table).

Code: Select all

<?php
$sql = "UPDATE chars SET 
        `mlmon` = $mlmon,
        `strlvlmon` = $strlvlmon,
        `strdmgmon` = $strdmgmon,
        `dexlvlmon` = $dexlvlmon,
        `dexcthmon` = $dexcthmon,
        `currlifemon` = $currlifemon,
        `currmaxlifemon` = $currmaxlifemon,
        `deflvlmon` = $deflvlmon,
        `defdamon` = $defdamon,
        `intlvlmon` = $intlvlmon,
        `foclvlmon` = $foclvlmon,
        `magmon` = $magmon,
        `magmaxmon` = $magmaxmon,
        `currlife` = $currlife";
?>

hmm

Posted: Wed Dec 20, 2006 2:34 am
by Mythic Fr0st
Okay

Code: Select all

$sql = "UPDATE chars SET
        `mlmon` = $mlmon,
        `strlvlmon` = $strlvlmon,
        `strdmgmon` = $strdmgmon,
        `dexlvlmon` = $dexlvlmon,
        `dexcthmon` = $dexcthmon,
        `currlifemon` = $currlifemon,
        `currmaxlifemon` = $currmaxlifemon,
        `deflvlmon` = $deflvlmon,
        `defdamon` = $defdamon,
        `intlvlmon` = $intlvlmon,
        `foclvlmon` = $foclvlmon,
        `magmon` = $magmon,
        `magmaxmon` = $magmaxmon,
        `currlife` = $currlife";
how would I add a WHERE idcount = $id
?

Posted: Wed Dec 20, 2006 2:59 am
by Chris Corbyn
I didn't read half of your post since it's too long, but for the </div> <div> parity issue run your HTML through a validator:

http://validator.w3.org/

This is good practise anyway if you want to follow standards :)

hmmm

Posted: Wed Dec 20, 2006 4:04 am
by Mythic Fr0st
Thanks, but its a mixture of PHP and HTML mainly PHP thats why I was trying to find a program with source folding, but I couldn't get ANY of them working, I did that, but sadly, the errors were mostly because of php being in there also

Re: hmm

Posted: Wed Dec 20, 2006 10:38 am
by RobertGonzalez
Mythic Fr0st wrote:Okay

Code: Select all

$sql = "UPDATE chars SET
        `mlmon` = $mlmon,
        `strlvlmon` = $strlvlmon,
        `strdmgmon` = $strdmgmon,
        `dexlvlmon` = $dexlvlmon,
        `dexcthmon` = $dexcthmon,
        `currlifemon` = $currlifemon,
        `currmaxlifemon` = $currmaxlifemon,
        `deflvlmon` = $deflvlmon,
        `defdamon` = $defdamon,
        `intlvlmon` = $intlvlmon,
        `foclvlmon` = $foclvlmon,
        `magmon` = $magmon,
        `magmaxmon` = $magmaxmon,
        `currlife` = $currlife";
how would I add a WHERE idcount = $id
?
If you go to the MySQL website and search for 'UPDATE syntax', then click the first link in the result list, it explains it.

I'd bet you can try this search type with other types of queries also, like 'SELECT syntax', 'INSERT syntax', 'DELETE syntax', 'UNION syntax' or even 'JOIN syntax'. The manuals are your friend, honestly. Being a good developer consists of many parts, one of which is the ability to find what you need in the manuals. :wink:

The Apache Manual (Version 2.2) (Version 2.0) (Version 1.3)
The MySQL Manual (Version 5.1) (Versions 3.23, 4.0, 4.1) (Version 5.0)
The PHP Manual (English version)

Posted: Wed Dec 20, 2006 4:12 pm
by Mythic Fr0st
<<never been good at looking for things in manuals XD
They're sooo big,


BTW if I do this

Code: Select all

$con=mysql_connect("Blah","PW","")
if (!$con)
{
die 'im cuter then bunnies';
}

$result=mysql("SELECT * FROM chars WHERE idcount = $id");
$row=mysql_fetch_array($result);
wouldnt that be easier then putting it on all of them?

the WHERE idcount = $id part

instead of Update blah blah, WHERE idcount = $id why not just select the database doing that