Skip site navigation (1) Skip section navigation (2)

Re: display query results

From: "Spiegelberg, Greg" <gspiegelberg(at)isodxsolutions(dot)com>
To: "PJ" <af(dot)gourmet(at)videotron(dot)ca>,<pgsql-php(at)postgresql(dot)org>
Subject: Re: display query results
Date: 2008-07-30 16:29:15
Message-ID: 82E74D266CB9B44390D3CCE44A781ED90B64DC@POSTOFFICE.cranel.local (view raw, whole thread or download thread mbox)
Lists: pgsql-php
You need to fetch the results.  See the pg_fetch_* family of functions for the one of your liking.
 $myarray = pg_fetch_all($results);


From: pgsql-php-owner(at)postgresql(dot)org on behalf of PJ
Sent: Wed 7/30/2008 10:18 AM
To: pgsql-php(at)postgresql(dot)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
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

        if (!$db)
        die("Could not open connection to database server");

         // generate and execute a query
        $query = "SELECT description FROM glossary_item WHERE
        $result = pg_query($db, $query) or die("Error in query: $query.
        " . pg_last_error($db));

        // Print result on screen
        echo "$result";


What am I doing wrong?

Sent via pgsql-php mailing list (pgsql-php(at)postgresql(dot)org)
To make changes to your subscription:

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information for the use of the designated recipients named above.  If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited.  If you have received this communication in error; please notify Cranel Incorporated immediately by telephone at 614-431-8000 or 800-288-3475 and destroy all copies of this communication and any attachments.

In response to


pgsql-php by date

Next:From: Matthias RitzkowskiDate: 2008-07-30 16:35:34
Subject: Re: display query results
Previous:From: PJDate: 2008-07-30 16:18:28
Subject: display query results

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group