Help with passing arrays between php scripts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Aha!

You have register_globals on so when your processing script starts
preselectvar has already had its values assigned. Then you assign the
form values to an element of preselectvar.

What you want to do is

Code: Select all

$preselectvar = $HTTP_POST_VARSї"preselectvar"];
don't include the []'s when you want to assign the whole array. In PHP the empty []s tell it to assign whatever come next to the first empty spot of the array, not to overwrite the whole array.
coolen
Forum Newbie
Posts: 19
Joined: Thu Aug 29, 2002 4:24 am
Location: Netherlands
Contact:

Post by coolen »

ok, thanks for all your help.

I do hope that the used construction is working for both setting from register_globals though :O(
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Yes the corrected version will work under either setting of register_globals. The incorrect version would have failed under either, but the array would have looked different.
Post Reply