Page 1 of 1
crazy error coming up randomly
Posted: Wed Jun 15, 2005 5:02 am
by shiznatix
i get this crazy error without warning
Warning: Illegal offset type in /home/users/andrew/public_html/cv/inc/lang.inc.php on line 1180
here is lang.inc.php
Code: Select all
var $text = array (
'CONTRACT_ID' => array
(
'est' => '*Contract ID*',
'eng' => 'Contract ID',
),
'CUSTOM_COMMENT' => array
(
'est' => '*Custom Comment*',
'eng' => 'Custom Comment',
),
'STATUS' => array
(
'est' => '*Status*',
'eng' => 'Status',
),
'NEW_CONTRACT' => array
(
'est' => '*New Contract*',
'eng' => 'New Contract',
),
);
function DoL($change)
{
if (isset($_SESSION['lang']))
{
//this next line is where it explodes
if(isset($this->text[$change][$_SESSION['lang']]))
{
echo $this->text[$change][$_SESSION['lang']];
}
}
else
{
trigger_error('No Language Set', E_USER_ERROR);
}
}
the array is supra much huger than that but you get the idea. It does this where everywhere that i use that function but it only does it randomly, i think maybe when i hit the back button a few times but maybe not. wtf does this mean!?
Posted: Wed Jun 15, 2005 5:04 am
by Syranide
illegal offset type e.g. you are trying to index by using an object or so... NULL too I guess (probably your problem if so).
echo all the indexes you use and you will most likely find the cause.
Posted: Wed Jun 15, 2005 5:17 am
by shiznatix
shwat?! what are these indexes you speak of and whatnot? its not null i am not using null for anything
and i just tested and it dosn't matter what im doing it just happens for no reason, like go to the same exact link that i am viewing now and bam explodes in my face but if i just reset my sessions then it all goes back to normal but until then i get that error
Posted: Wed Jun 15, 2005 5:20 am
by Syranide
echo $this->text[$change][$_SESSION['lang']];
indices are (not indexes, indices right?)
$change and $_SESSION['lang']
if $_SESSION['lang'] doesn't exist, it will be NULL, and NULL is not a valid index in an array... illegal (evil cops with batons will knock on your door)
Posted: Wed Jun 15, 2005 5:26 am
by shiznatix
but wouldnt the
keep the police from even knowing that i could do a illigal operation? and this is the only session that seams to go all crazy, all the other sessions work fine
Posted: Wed Jun 15, 2005 5:31 am
by Syranide
The only way to create illegal offsets is NULL/boolean/object/resource/array (I think) ... uhm something more ... and none of those (perhaps boolean) sounds like they could be accidentally set, as I said, dump all variables $_SESSION['lang'] and so on, and when it freaks, you'll see what they were.
(Yes you were right about NULL/isset)
Posted: Wed Jun 15, 2005 5:35 am
by shiznatix
ok i have print_r($_SESSION); at the bottom of the page and next time it explodes ill report back my findings
Posted: Wed Jun 15, 2005 5:37 am
by Syranide
you might want to do a var_dump to see what type they truly are.
Posted: Wed Jun 15, 2005 6:15 am
by shiznatix
o dear god. it happened and i had the var_dump and whatnot. what happens is that for whatever god aweful reason the $_SESSION['lang'] gets set to the entire array of possible words instead of just being eng or est. that makes absolutly no sence to me. Here is all the functions that are in my language class
Code: Select all
function SetLang($lang)
{
if ($lang !== 'eng' && $lang !== 'est')
{
trigger_error('Invalid Language', E_USER_ERROR);
}
else
{
$_SESSION['lang'] = $lang;
}
}
function DoL($change)
{
if (isset($_SESSION['lang']))
{
if(isset($this->text[$change][$_SESSION['lang']]))
{
echo $this->text[$change][$_SESSION['lang']];
}
}
else
{
trigger_error('No Language Set', E_USER_ERROR);
}
}
and i posted earlier a section of my language array. why all of a sudden would session lang be set to a object...
...taken from print_r...
Code: Select all
Array
(
їlang] => lang Object
(
їtext] => Array
(
їFORM_USERNAME] => Array
(
їest] => *Username*
їeng] => Username
)
//it goes on for about 2000 lines
wtf is up with that!? and why does it only happen randomly?
Posted: Wed Jun 15, 2005 1:52 pm
by shiznatix
sorry *bump*
is my question not clear or is this completly unexplainable (which for me it is)
Posted: Fri Jun 17, 2005 6:31 am
by shiznatix
last bump. Does nobody have and ideas or anything? maybe you need to see the entire script and if so pm/msn/aim me and i will show you more (its too long of files to put here) but i really need help on this because its completly got me stumped.
Posted: Fri Jun 17, 2005 6:41 am
by phpScott
keep an eye on what you are doing before it goes nuts maybe there is a clue there.
look where else you might be playing with similar code on an include page or something.
In programming things don't happen randomly unless you want them too. There is a logic error somewhere and those are always the hardest to figure out.
Take a day off from this part of the code them come back too it and it might leap out at your.