Received: from hapcibeno.freestart.hu (hapcibeno.freestart.hu [213.197.64.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9DE1lr79539 for ; Sat, 13 Oct 2001 10:01:48 -0400 (EDT) (envelope-from pgerzson@freestart.hu) Received: from erinyes.freestart.hu ([213.197.64.251]) by freestart.hu with esmtp (Freestart relay 2 (FS-Lin)) id 15sPaZ-0006Vm-00; Sat, 13 Oct 2001 16:16:31 +0200 Received: from line-74-140.dial.freestart.hu ([213.197.74.140] helo=jaguar) by erinyes.freestart.hu with smtp (Exim 3.32 #1 (Debian)) id 15sPUX-0005an-00; Sat, 13 Oct 2001 16:10:17 +0200 Message-ID: <00bc01c153ef$b5d1cfc0$01fdfea9@jaguar> From: "Papp Gyozo" To: "Zavier Sheran" , References: <20011013045140.50099.qmail@web14401.mail.yahoo.com> Subject: Re: Nextval again Date: Sat, 13 Oct 2001 15:11:03 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Scanner: exiscan by Freestart X-Archive-Number: 200110/50 X-Sequence-Number: 603 Hello, > I did run different queries like No matter what queries are executed as long as they are valid. :) > > $number = pg_Exec ($db_connect, "SELECT > nextval('members_recordid_seq')"); > > $number = pg_Exec ($db_connect, "SELECT last_value > FROM members_recordid_seq"); > > What I get when I "echo $number;" is "Resource id #2", > no matter what number the sequence is at (currently > 19). Yes, because as the PHP manual says: pg_Exec() returns a valid resource id on success, or FALSE on failure. It means that you have to fetch the rows from the result set pointed by this resource id. To describe it very loosely, the resource id only points to a memory location where the rows returned by a SELECT statement are stored. So you must : $result = pg_exec($db_connnect, "SELECT -- your query goes here...;"); for ($row = 0; $row < pg_numrows($result); $row++) { $record = pg_fetch_row($result, $row); print_r($record); } //if you are interested only a specific row (ie.: thwe 1st one, like above) $result = pg_Exec ($db_connect, "SELECT nextval('members_recordid_seq')"); list($number) = pg_fetch_row($result, 0); // row numbering starts from 0. > > If I run the same queries in phpPgAdmin I get the > correct results. phpPgAdmin does this fetching automatically. > I run PHP 4.04 and PgSQL 7.03 You are strongly encouraged to upgrade both. > Any ideas? > > __________________________________________________ > Do You Yahoo!? > Make a great connection at Yahoo! Personals. > http://personals.yahoo.com > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html