pthurmond Posted November 23, 2006 Share Posted November 23, 2006 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 More sharing options...
ataria Posted November 23, 2006 Share Posted November 23, 2006 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 More sharing options...
joshi_v Posted November 23, 2006 Share Posted November 23, 2006 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! :)Regardsjoshi Link to comment https://forums.phpfreaks.com/topic/28204-passing-arrays/#findComment-129019 Share on other sites More sharing options...
pthurmond Posted November 23, 2006 Author Share Posted November 23, 2006 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 38Here 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 More sharing options...
JasonLewis Posted November 23, 2006 Share Posted November 23, 2006 is $centerarray an array... or is $_SESSION['report_centers'] an array. try going like this:[code=php:0]print_r($centerarray);[/code]and check to see if it is actually an array. should look something like Array( [0] Var1 => Hello ) Link to comment https://forums.phpfreaks.com/topic/28204-passing-arrays/#findComment-129043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.