Page 1 of 1

Problem with a value not being set, dont know why

Posted: Sat Dec 09, 2006 11:01 pm
by Mythic Fr0st
Ok, basically I have a little setup...

You select the monster out of a dropdown box, they have values (1, 2, 3, 4) now

(that is my list to show what your attacking (it shows, you are attacking $_SESSION['currmonster']) which is set to those, works fine, but some reason... it doesnt set the value right for the stats etc..

Code: Select all

$mon1[1]='Baby Elf';
$mon1[2]='Wood Elf';
$mon1[3]='Dark Elf';
$mon1[4]='Blood Elf';
(the isset($_POST['monisters'] stops the notices from showing up (dont know what else it does though)

Code: Select all

if (isset($_POST['monsters']))
{
($monsters, suppost to get the value from the dropdown box (1,2,3,4))
$monsters = $_POST['monsters'];
(Currmonster, gets set to $mon1[$monsters]; which also works fine, even if I change what monster im fighting, it updates it properly)

Code: Select all

$_SESSION['currmonster']=$mon1[$monsters];
$_SESSION['MLmon']=$monsters;
}
now that should (SHOULD!) have the value of 1,2,3,4 but nooo it doesnt... for unknown reasons...

>>code right below the above code>

Code: Select all

if (!isset($_SESSION['dexlvlmon'])) 
{$_SESSION['dexlvlmon']=$_session['MLmon'] * 5;}
if (!isset($_SESSION['dexcthmon'])) 
{$_SESSION['dexcthmon']=0;}
//if (!isset($_SESSION['mba=mon'])) //monster being attked
//{$_SESSION['mba=mon']=true;}
if (!isset($_SESSION['deflvlmon'])) 
{$_SESSION['deflvlmon']=$_SESSION['MLmon'] * 4;}
if (!isset($_SESSION['defptmmon'])) 
{$_SESSION['defptmmon']=0;}
if (!isset($_SESSION['strlvlmon'])) 
{$_SESSION['strlvlmon']=$_SESSION['MLmon'] * 7;}
if (!isset($_SESSION['currlifemon'])) 
{$_SESSION['currlifemon']=$_SESSION['MLmon']*13;}
if (!isset($_SESSION['currmaxlifemon'])) 
{$_SESSION['currmaxlifemon']=$_SESSION['MLmon']*13;}
if (!isset($_SESSION['defdamon'])) 
{$_SESSION['defdamon']=$_SESSION['MLmon']*$_SESSION['deflvlmon'];}
if (!isset($_SESSION['strdmgmon']))
{$_SESSION['strdmgmon']=$_SESSION['strlvlmon']/4;}
if (!isset($_SESSION['mondropgold']))
{$_SESSION['mondropgold']=$_SESSION['MLmon'];}
thats suppost to divvy up the stats by MLmon * x, (MLmon, Main Level Monster fyi)

However that doesnt seem to happen? Im really confused can anyone help?

(it kinda makes it easier, being able to just increase the MLmon (main level monster) to make em stronger)

Posted: Wed Dec 27, 2006 6:26 am
by jyhm
I don't know how you are handleing the code but you might be messing up your arrays by setting the first value index as one. Array indexes always start at index 0.

Code: Select all

$mon1[1]='Baby Elf';
$mon1[2]='Wood Elf';
$mon1[3]='Dark Elf';
$mon1[4]='Blood Elf';
this might be leaving index zero empty, resulting in;

Code: Select all

array (  0=> 
          1=>Baby Elf 
          2=>Wood Elf 
          3=>Dark Elf 
          4=>Blood Elf
)

//use this statement to analyze your array,..

echo '<pre>';
print_r($mon1);
echo'</pre>';