Jump to content

Passing arrays....


pthurmond

Recommended Posts

Ok, I know I keep kicking these questions out there, but this forum has been an invaluable resource. When I get some money flowing again I will definitely donate to this site (which will hopefully be within the next few weeks).

Anyways, I have been able to pass an array within a $_POST variable. But I am having trouble with sessions. Can arrays be passed from script to script with the $_SESSION superglobal? If not, the problem I am trying to solve is that I want to have a script self-process to ensure all the required data is input before moving on to the final report screen. The main issue with this is one piece of data is an array of variables that is built dynamically. There is not predetermined number of these items that need to be passed. That is why an array must be used. It is a list of id numbers. Is there another way to pass this array without using the session superglobal while still allowing the first script to self-process?

As always I really appreciate all of the help that is offered here.

Thanks,
Patrick
Link to comment
https://forums.phpfreaks.com/topic/28204-passing-arrays/
Share on other sites

Wait.
Are you trying to do something that is like..
the ID is made in the same script that you want to insert the ID in?
such as..
a forum..
like, making a board and then insert the board ID in the first post?
(the page will have both fields, title (or board) and first post.)

if so..
$insertid = mysql_insert_id();

... I don't think I understood...
Link to comment
https://forums.phpfreaks.com/topic/28204-passing-arrays/#findComment-129016
Share on other sites

Well! you can't really pass an directly from one form to another.If you want to do it still , at the end of the script , take the araay and make it as a string using a deliemter and 'implode()' statement and post it to next script.In next script again have to use explode command with delimeter you put in previous page to form the array again.

About sessions..i think we can pass an array using a session, if an array is assigned to session variable.

If i am wrong ,any one could update me! :)

Regards
joshi
Link to comment
https://forums.phpfreaks.com/topic/28204-passing-arrays/#findComment-129019
Share on other sites

Well when I pass the array I get the following error:
Warning: Invalid argument supplied for foreach() in /home/phatgod/public_html/PALsys/report_yarmb.php on line 38

Here is the code to grab it.
[code]
$centerarray = $_SESSION['report_centers'];
$date1 = $_SESSION['report_date1'];
$date2 = $_SESSION['report_date2'];

foreach($centerarray AS $center)
{
}
[/code]

I am guessing that it is not passing correctly. But when I pass it to SESSION it is just the reverse of the first line of code.
Link to comment
https://forums.phpfreaks.com/topic/28204-passing-arrays/#findComment-129023
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.