X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B4821D1C7F1 for ; Wed, 13 Aug 2003 18:18:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53630-01 for ; Wed, 13 Aug 2003 15:17:04 -0300 (ADT) Received: from wolf.urban.csuohio.edu (wolf.urban.csuohio.edu [137.148.96.16]) by svr1.postgresql.org (Postfix) with ESMTP id A5F9DD1B53A for ; Wed, 13 Aug 2003 15:18:15 -0300 (ADT) Received: from ssbeagle (mail@UB-LL-02137-148-91-240.dhcp.csuohio.edu [137.148.91.240]) by wolf.urban.csuohio.edu (8.12.9/8.12.9) with ESMTP id h7DIHrRb006805 for ; Wed, 13 Aug 2003 14:18:04 -0400 (EDT) Received: from cmr by ssbeagle with local (Exim 3.36 #1 (Debian)) id 19n0C0-0005uS-00 for ; Wed, 13 Aug 2003 14:17:52 -0400 Date: Wed, 13 Aug 2003 14:17:52 -0400 From: cmr@shell.gis.net To: pgsql-php@postgresql.org Subject: Re: problems when fetching array contents. Message-ID: <20030813181752.GA16982@ssbeagle> Reply-To: pgsql-php@postgresql.org References: <000401c361bf$b2b378e0$2201a8c0@naboo> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000401c361bf$b2b378e0$2201a8c0@naboo> User-Agent: Mutt/1.5.4i X-MailScanner-Information: Please contact the help desk (x2200) for more information X-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/51 X-Sequence-Number: 2228 On Wed, Aug 13, 2003 at 07:24:03PM +0200, J0nEz wrote: > Hello, > > I'm having problems fetching array contents. > > Connection to my db is alright, the db data too. > > Here is the problem: > > I have a table named "configuration" containing Keys and Values of > Constants that have to be defined in php. > > The code: > > $configuration_query = pg_query("select configuration_key as cfgKey, > configuration_value as cfgValue from configuration"); > If this is your actual code, you are not passing the connection resource variable to pg_query. (see here: http://us4.php.net/manual/en/function.pg-query.php ) > while ($configuration = tep_db_fetch_array($configuration_query)) { > echo $configuration['cfgKey']; $configuration['cfgValue']; // test > define($configuration['cfgKey'], $configuration['cfgValue']); > } > I would do a pg_fetch_array, and then foreach through the array like this: $query_rows = pg_num_rows($resource_from_pg_query); for($iterator = 0; $iterator < $query_rows; $iterator++) { $my_db_array = pg_fetch_array($resource_from_pg_query) foreach ($my_db_array as $mdba_name => $mdba_value) { define("$mdba_name", "$mdba_value"); } } then a print_r(get_defined_vars) should give you your vars.. Hope this helps! Chadwick