I'm trying to put a multidimensional array into a cookie. but everytime i do it the page crashes. does anyone know more about multidimensional things? session_start(); require_once('function.php'); $online_list = $_SESSION['online_list']; $friend = $_GET['user_id']; $online_list = array(); $stack = array( "$friend" => array( "display" => "0" ) ); array_push($statck, $online_list); $_SESSION['online_list'] = $online_list; unset($_SESSION['online_list']); i also tried $online_list = $_SESSION['online_list']; $friend = $_GET['user_id']; if(!empty($online_list)){ $online_list = array(); $online_list["0"]["user_id"] = $friend; $online_list[$num]["online"] = 0; $_SESSION['online_list'] = $online_list; } else{ $num = count($online_list); $online_list[$num]["user_id"] = $friend; $online_list[$num]["online"] = 0; $_SESSION['online_list'] = $online_list; thanks to all. I'm stumped
Not sure is this is a typo, should be $stack, right? array_push($statck, $online_list); PHP: also on the second part, you didn't assign a variable for $num in the IF before the ELSE $online_list[$num]["online"] = 0; PHP:
thanks man i amended the stack variable but it still crashed. the online num line i just forgot, but its supposed to be session_start(); require_once('bookmark_fns.php'); $online_list = $_SESSION['online_list']; $friend = $_GET['user_id']; if(!empty($online_list)){ $online_list = array(); $online_list["0"]["user_id"] = $friend; $online_list[$num]["online"] = 0; $_SESSION['online_list'] = $online_list; } else{ $num = count($online_list); $online_list[$num]["user_id"] = $friend; $online_list[$num]["online"] = 0; $_SESSION['online_list'] = $online_list; } anyway i was guessing this must just be a really inefficent method. this php is code is repeated once every 100 miliseconds. so i cranked it up to 1000 then 100000. still crashes. What i'm trying to do is assosiate a user id with with a boolean. i was thinking aboutstoring the bool in the same array cell as the id and then doing a string separation since the user ids are always 13 char long and this multi dimensional array buissnes isnt working.Anyone know if that would be more efficent or better way? Thanks for the response narrator.
What do you mean by crash? Do you get a PHP error, does the site time out, or does your actually browser crash/freeze/stop responding?
You were still missing the $num, try this session_start(); require_once('bookmark_fns.php'); $online_list = $_SESSION['online_list']; $friend = $_GET['user_id']; if(!empty($online_list)){ $num = count($online_list); //you were missing this not sure if it was the prob $online_list = array(); $online_list[0]["user_id"] = $friend; //dont need to quote the 0 but I doubt that was the prob $online_list[$num]["online"] = 0; $_SESSION['online_list'] = $online_list; } else{ $num = count($online_list); $online_list[$num]["user_id"] = $friend; $online_list[$num]["online"] = 0; $_SESSION['online_list'] = $online_list; } PHP:
Sorry i managed not to define $num again. Anyway when the page crashes the current tab stops responding to all clicks, then after 30 or so seconds the page goes white. if u reload the page though the cookie has the right info. I'll try putting all the info in 1 one string. But if anyone knows about multidimensional array bracket syntax i would be super grateful. thanks for all the responses guys
Wow my bad. I read over my own description of the array. And realized that this was a javascript problem. found and fixed the error. Anyway thanks to all for respondin even if i am a moron