X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4D989D1B1B6 for ; Wed, 19 May 2004 23:47:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 26402-05 for ; Wed, 19 May 2004 23:47:18 -0300 (ADT) Received: from dnscache2.syd.nexon.com.au (dnscache2.syd.nexon.com.au [210.215.48.100]) by svr1.postgresql.org (Postfix) with ESMTP id 52EF3D1B1C7 for ; Wed, 19 May 2004 23:47:13 -0300 (ADT) Received: from chris ([210.215.130.98]) by dnscache2.syd.nexon.com.au (8.12.8p1/8.12.8) with ESMTP id i4K2nvKw050966; Thu, 20 May 2004 12:49:58 +1000 (EST) (envelope-from chris@interspire.com) From: "Chris" To: "'Lynna Landstreet'" , Subject: Re: Sessions and serializing (was: Checking data inserted Date: Thu, 20 May 2004 12:46:54 +1000 Message-ID: <001c01c43e14$b69eb960$0d00a8c0@chris> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/38 X-Sequence-Number: 2757 Hi Lynna, on 5/12/04 7:36 PM, Chris at chris@interspire.com wrote: > You could serialize up the data in sessions and then use that data > before adding it to the database. See http://www.php.net/serialize and > http://www.php.net/unserialize and http://www.php.net/session > OK, so if I understand this correctly, the serialize function can take something like a big associative array containing all the data I want to be able to write into the database and condense it into a single object that can be passed via a hidden form field or something to that effect, correct? Or the data can be put into the session array using $_SESSION, and then passed by using a $session_id in the page URL? You won't need to use unserialize and serialize per page if you're going to use sessions - you only need those if you're going to pass the values in a URL or in a hidden form field. For sessions, you can simply $my_array = array('1','2','3','4','5'); $_SESSION['blah'] = $my_array; sort of thing.. > But according to one of the user comments in the manual I have to use > addslashes() and stripslashes() if I want to be able to put the data into the database after unserializing it - is that right? Yep. So you'll need to do $value = addslashes(serialize($real_value)); and use $value in your query... Then when you fetch out $real_value = unserialize(stripslashes($value)); Done =) > Also, what about character encoding? My database and my web pages are utf-8 because of the presence of special characters in some of the artists and names and image and exhibition titles (it's a Canadian gallery, so there are a lot of French artists). Will serializing the array containing the data affect that in any way? Not as far as I know, it should handle that fine. > Sorry if I'm being a pest - the whole session thing is new to me and I want to make sure I understand it correctly. Ask as many questions as you need to, we've all been at the start before =)