Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 69E2F650175 for ; Wed, 30 Jul 2008 14:44:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 43454-04 for ; Wed, 30 Jul 2008 14:44:10 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id 90DA2650090 for ; Wed, 30 Jul 2008 14:44:11 -0300 (ADT) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=ISO-8859-1; format=flowed Received: from [192.168.0.51] ([96.21.103.185]) by VL-MO-MR002.ip.videotron.ca (Sun Java(tm) System Messaging Server 6.3-4.01 (built Aug 3 2007; 32bit)) with ESMTP id <0K4T002KPYLMIS40@VL-MO-MR002.ip.videotron.ca> for pgsql-php@postgresql.org; Wed, 30 Jul 2008 13:44:10 -0400 (EDT) Message-id: <4890A871.3020906@videotron.ca> Date: Wed, 30 Jul 2008 13:44:17 -0400 From: PJ User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) To: "Spiegelberg, Greg" Cc: pgsql-php@postgresql.org Subject: Re: display query results References: <48909454.7040305@videotron.ca> <82E74D266CB9B44390D3CCE44A781ED90B64DC@POSTOFFICE.cranel.local> In-reply-to: <82E74D266CB9B44390D3CCE44A781ED90B64DC@POSTOFFICE.cranel.local> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/5 X-Sequence-Number: 3869 I've been looking at the pg_fetch_* functions but do not understand one little bit. Using your suggestion gives a blank screen but var_dump($myarray) gives "bool(false)" And a var_dump($results) returns "resource(3) of type (pgsql result) while print_r($results) returns "Resource id#3" I'm totally lost. :( Perhaps my query isn't well formulated? What I am trying to locate (or print out) is the string found the "description" column whre the row in the "name" column is Alcohol. item_id || glossary_id || name || description 2 || 2 || Alcohol || One of thetwo major.... blah...blah.. blah Spiegelberg, Greg wrote: > You need to fetch the results. See the pg_fetch_* family of functions > for the one of your liking. > > $myarray = pg_fetch_all($results); > print_r($myarray); > > Greg > > ------------------------------------------------------------------------ > *From:* pgsql-php-owner@postgresql.org on behalf of PJ > *Sent:* Wed 7/30/2008 10:18 AM > *To:* pgsql-php@postgresql.org > *Subject:* [PHP] display query results > > I am trying to learn postgresql with psql - using FreeBS D7.0, > postgresql 8.3.3 php 5.2.6, apache 2.2.9 > > How can I echo or print on screen the results; all I get from this code > is this: > Resource id #3 > item_idglossary_idnamedescription > which is the field names run together > > I am expecting to see several long text sentences. > > Here is the snippet and the connection does work and the database is > there and functioning. > > $db = pg_connect("host=localhost port=5432 dbname=med user=med > password=0tscc71"); > > if (!$db) > { > die("Could not open connection to database server"); > } > > // generate and execute a query > $query = "SELECT description FROM glossary_item WHERE > name='Alcohol'"; > $result = pg_query($db, $query) or die("Error in query: $query. > " . pg_last_error($db)); > > // Print result on screen > echo "$result"; > > pg_close($db); > > What am I doing wrong? >