ann Posted November 15, 2006 Share Posted November 15, 2006 HiIn short I want to be able to pass a 2D array from one php script to another.I've got a MAIN php script which draws a map of links and then calls another php to draw a 'clickable' image over the top of the links. The data for the links and the image are the same so I want to pass the array of data to the image script.If anyone can tell me how it's done, or where I'm going wrong with what I'm trying below, I'd be very greatful :)thanksThis is giving me an error that I can't find a solution to...the MAIN script where the 2D array ($doms) is created...[code] # $doms is the 2D array I want to pass $data = serialize($doms); #$data = base64_encode(serialize($doms)); print("$data<br>"); print("<IMG border=0 USEMAP=\"#map$dir\"SRC=\"prot_img.php?protein=$protein&data=$data\"></img>"); $doms = unserialize($data); #$doms = base64_decode(unserialize($data)); print_r($doms);[/code]the script where I want to pass the array to...[code]$doms=unserialize($_GET["data"]); ##line14[/code]and the error I get is...[code]PHP Notice: unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 19 of 23 bytes in prot_img.php on line 14,[/code] The unserialize works within the MAIN script but not when it's passed. The base64 encoding in MAIN works but the decoding fails and I get the same unserialize() error for both scripts if I use the base64 encoding. Link to comment https://forums.phpfreaks.com/topic/27352-passing-2darray-between-php-scripts/ Share on other sites More sharing options...
kenrbnsn Posted November 15, 2006 Share Posted November 15, 2006 You could pass the array via a session variable.In the main script:[code]<?phpsession_start();$_SESSION['data'] = $data;print("<IMG border=0 USEMAP=\"#map$dir\"SRC=\"prot_img.php?protein=$protein\"></img>");?>[/code]In the prot_img.php script:[code]<?phpsession_start();$data = $_SESSION['data'];?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/27352-passing-2darray-between-php-scripts/#findComment-125065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.