RE: [PHP] Array to $_GET variable

From: Date: Thu, 11 Nov 2004 04:57:03 +0000
Subject: RE: [PHP] Array to $_GET variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-201735@lists.php.net to get a copy of this message
Hi, Yes it is a good idea to store this value in $_SESSION array. $_GET value sometime (depend on php setting) add slashes to all values, Those slashes will create the problem at the time of unserialization. Doing urlencode and decode also can be help full but in my view $_SESSION are best way to manage this as sometime value may be too long to store in $_GET variable. Do You get any error on unserialization? Zareef ahmed -----Original Message----- From: Mike Smith [mailto:mikeosmith@gmail.com] Sent: Wednesday, November 10, 2004 10:14 PM To: php-general@lists.php.net Subject: [PHP] Array to $_GET variable I am trying to cache a database recordset so users can sort, etc without hitting the database everytime. I'm using ADODB to access a MSSQL database. $s = "SELECT id, part, description FROM parts\n"; $r = $db->Execute($s); $parts = array(id=>array(),part=>array(),desc=>array()) while(!$r->EOF){ array_push($parts['id'],$r->fields[0]); array_push($parts['part'],$r->fields[0]); array_push($parts['desc'],$r->fields[0]); $r->MoveNext(); } // print_r($parts) displays array data. Here's what I'm doing: $v = serialize($parts); echo "<a href=\"{$_SERVER['PHP_SELF']}?getvar=$v\">Link</a>\n"; If($_GET['getvar']){ $newvar = unserialize($_GET['getvar']); //This does nothing echo $newvar; print_r($newvar); } Am i missing something very simple? Should I make the array a $_SESSION variable, or how do others "cache" a recordset? ------------------------------------------------------------------------ -- Zareef Ahmed :: A PHP develoepr in Delhi ( India ) Homepage :: http://www.zasaifi.com

« previous php.general (#201735) next »