--> Really weird problem!!
Moderator: General Moderators
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
--> Really weird problem!!
Hi guys,
this is just crazy.
My php script works just fine except sometimes. Then I get a <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> up output and after a couple of minutes an error message, something about "unsupported operand types in row blablabla". In these rows the script does this:
$my_array[$counter-1][]="this is a string";
Are there known bugs with decrementing variables while assigning them to an array ?!
Funny thing is, it works just fine for quite some time and then it starts to do this crap.
Could this be session problems or something? I only store administrative stuff like login name and so on in the session, not the data itself (meaning not the array from the example above).
Can anybody help?
My boss is driving me nuts, he claims this is a script error which I find hard to believe since the script worked fine for days and started misbehaving at times just today ... *narf*
this is just crazy.
My php script works just fine except sometimes. Then I get a <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> up output and after a couple of minutes an error message, something about "unsupported operand types in row blablabla". In these rows the script does this:
$my_array[$counter-1][]="this is a string";
Are there known bugs with decrementing variables while assigning them to an array ?!
Funny thing is, it works just fine for quite some time and then it starts to do this crap.
Could this be session problems or something? I only store administrative stuff like login name and so on in the session, not the data itself (meaning not the array from the example above).
Can anybody help?
My boss is driving me nuts, he claims this is a script error which I find hard to believe since the script worked fine for days and started misbehaving at times just today ... *narf*
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
I got a little closer to the problem, unfortunately I still don't have an explanation.
I got a script called "A" with a big switch-case in it. Depending on what value a variable got, there will be another file included (with the switch-case).
Well, all of these included php scripts are somewhat alike, using variables with same names. This is not a problem, since there will never be more than one script included. BUT - out nice and kind PHP thingie seems to store the values of certain variables.
e.g. i use that variable $header and i did not initialize it but assigned the values directly:
$header['header1']=2;
$header['header2']=22;
$header['header3']=24;
$header['header4']=72;
i do this with different values in in different scripts ... which are never called at the same time ... and php just APPENDS the values, but not in an ordered way but randomly.
i wrote an $header=array(); on top of each script and now its working fine ...
but why is it doing this in the first place?!
I got a script called "A" with a big switch-case in it. Depending on what value a variable got, there will be another file included (with the switch-case).
Well, all of these included php scripts are somewhat alike, using variables with same names. This is not a problem, since there will never be more than one script included. BUT - out nice and kind PHP thingie seems to store the values of certain variables.
e.g. i use that variable $header and i did not initialize it but assigned the values directly:
$header['header1']=2;
$header['header2']=22;
$header['header3']=24;
$header['header4']=72;
i do this with different values in in different scripts ... which are never called at the same time ... and php just APPENDS the values, but not in an ordered way but randomly.
i wrote an $header=array(); on top of each script and now its working fine ...
but why is it doing this in the first place?!
php's implementation of arrays is more like a list - but not a sorted list.
Take a look at the different sort functions, e.g. http://php.net/ksort
Take a look at the different sort functions, e.g. http://php.net/ksort
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
when the site is called first, $header has the values of this first call. at a second call, $header has the vaules of that second call plus the values of the first call. but these values are not attached to the head or tail of the array, but they are randomized. also, not every value is attached.
the more often you call the script, the bigger $header grows.
ich mach das mal in deutsch:
damit meine ich, daß php an die $header variable die werte von frührern aufrufen dranpappt, aber nicht in der reihenfolge wie sie aufgerufen wurden, sondern wild aneinandergepappt.
the more often you call the script, the bigger $header grows.
ich mach das mal in deutsch:
damit meine ich, daß php an die $header variable die werte von frührern aufrufen dranpappt, aber nicht in der reihenfolge wie sie aufgerufen wurden, sondern wild aneinandergepappt.
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
Nee $header ist schlicht und einfach ein Array, das hartcodiert initialisiert wird. Die Dimension ist der Name der Überschrift und der Wert die Position des Parameters im Input String.
$header['IP-Adresse']=5;
Die IP-Adresse befindet sich an 5ter Stelle im Input String.
Ich benutze das, um möglichst dynamisch Tabellen darzustellen. So muß ich nur an einer Stelle die Skripte anpassen. Jedenfalls, wenn ich über diese $header-Inits ein $header=array() schreibe, also das Ding "richtig" initialisiere, ist das Phänomen weg.
Hat mich echt Nerven gekostet ... auf so ne blöde Idee mußt du erst mal kommen!
$header['IP-Adresse']=5;
Die IP-Adresse befindet sich an 5ter Stelle im Input String.
Ich benutze das, um möglichst dynamisch Tabellen darzustellen. So muß ich nur an einer Stelle die Skripte anpassen. Jedenfalls, wenn ich über diese $header-Inits ein $header=array() schreibe, also das Ding "richtig" initialisiere, ist das Phänomen weg.
Hat mich echt Nerven gekostet ... auf so ne blöde Idee mußt du erst mal kommen!