|
Posted by drako on 01/18/07 20:24
OK,
Here is the code in its entireity:
[It is wrapped around an IF statement to process upon a certain
condition].
if($_POST['increment'] == 1) {
$x = 0;
if(isset($_SESSION["increment"])) {$x =
count($_SESSION["increment"]);}
$_SESSION["increment"][$x] = array("increment_bond" =>
$_POST["increment_bond"],
"increment_amount" => $_POST["increment_amount"],
"increment_comm_date1" => $_POST["increment_comm_date1"],
"increment_comm_date2" => $_POST["increment_comm_date2"],
"increment_comm_date3" => $_POST["increment_comm_date3"]);
}
Rik wrote:
> Erwin Moller wrote:
> > Rik wrote:
> >>> I now suspect this is session-related in someway. As the code looks
> >>> OK, the problem arises from elsewhere....
> >>
> >> Nope.
> >> Keep in mind, that on strings, the [] will get or set the character
> >> of the string at that particular location. My suspicion is that you
> >> don't give us the real code (for where would the incrementation take
> >> place?), and you turn the array into the string ( or number) '1'
> >> somewhere. (This often happens when you use the return of a function
> >> (true) that works be a reference instead of a return by accident.)
> >>
> >> So, in the first loop, we've made $_SESSION["increment"] into a
> >> string by accident. On the second loop, if $x = 1, that's the
> >> second position in the string (which was not previously set). You
> >> try to set a character to an array, so the array is converted to a
> >> string ('Array'), then it takes the
> >> first character ('A') from that string, and put it at position 1.
> >> Hence resulting in '1A'.
> >>
> >> If you gave us the real code, I'd bet we'd spot where the actual
> >> overriding on $_SESSION["increment"] takes place.
> >
> > Damn Rik, sometimes you are scaringly smart.
>
> Well, that remains to be seen, but thank you, would be nice if I would get
> paid that way though :-)
>
> > That sounds like a very probable scenario you described and deducted
> > from the sparse information given.
>
> It helps that I cannot get the difference of array_walk() and array_map in
> my head, so I'm used to seeing some '1''s or 'A's..
>
> Now let's get the OP to post the code he uses in it's entirety to claim my
> fame :-)
> --
> Rik Wasmus
Navigation:
[Reply to this message]
|