Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 18E6B650214 for ; Wed, 30 Jul 2008 19:46:39 -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 21677-05 for ; Wed, 30 Jul 2008 19:46:29 -0300 (ADT) X-Greylist: delayed 02:08:23.991342 by SQLgrey-1.7.6 Received: from smtp-gw3.mailanyone.net (smtp-gw3.mailanyone.net [208.101.54.178]) by postgresql.org (Postfix) with ESMTP id E6AD2650207 for ; Wed, 30 Jul 2008 19:46:33 -0300 (ADT) Received: from smtp-gw31.mailanyone.net ([208.70.128.57]) by smtp-gw3.mailanyone.net with esmtp (Exim 4.69) (envelope-from ) id 1KOIQx-0006Lp-2E for pgsql-php@postgresql.org; Wed, 30 Jul 2008 15:38:07 -0500 Received: from mailanyone.net by smtp-gw31.mailanyone.net with esmtpa (MailAnyone extSMTP andy@networkmail.eu) id 1KOIQp-0003jR-0f; Wed, 30 Jul 2008 15:37:59 -0500 Message-ID: <4890D124.7020506@mailnetwork.co.uk> Date: Wed, 30 Jul 2008 21:37:56 +0100 From: Andy Shellam User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: PJ CC: Lynna Landstreet , pgsql-php@postgresql.org Subject: Re: display query results References: <48909454.7040305@videotron.ca> <82E74D266CB9B44390D3CCE44A781ED90B64DC@POSTOFFICE.cranel.local> <4890A871.3020906@videotron.ca> <4890AA8C.9080907@spidersilk.net> <4890CA07.2040405@videotron.ca> In-Reply-To: <4890CA07.2040405@videotron.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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/16 X-Sequence-Number: 3880 PJ wrote: > Lynna Landstreet wrote: > Well, it does explain things a little. Unfortunately, I have tried > about everything imaginable before posting except the right thing. > I can not visualize what it is that my query is returning. Here is > what the code is: > > Whatever I enter as values for pg_fetch_result, the screen output is : > > resource(3) or type (pgsql result) > *Warning*: pg_fetch_result() [function.pg-fetch-result > ]: Unable to jump to row 1 > on PostgreSQL result index 3 in > */usr/local/www/apache22/data/k2/test1_db.php* on line *29* This suggests that there is no row 1 in your result-set. I believe it is zero-based, so try fetching row 0 if your query only returns 1 row. > I don't understand what $resuts is returning - if it is an entire row, > the one that the field is in that I am looking for, then why do I not > get a printout of the text that is in that field? The row in the table > is the second row and the field I am trying to retrieve is the 4th field. $results as explained previously is just a pointer to a recordset. This analogy isn't brilliant, but think of your database table as a book. Each row on a page within that book is a record, and the words in that row are the data in the table's columns. When you run a query, think of yourself looking at the book's index for a given word. The index will tell you the pages that word is on. That's your $results - simply a pointer to your data. You then need to turn to that page in the book (pg_fetch_* functions) to start examining the lines for the word you want. Once you've got your line, you can find the word (column/data, from your array) you're looking for. Now turn that into PHP and SQL. You run your query (looking in the book's index) and the PostgreSQL driver will save the results into a block of memory in your server's RAM, returning a resource identifier. This is literally just saying "resource #3 is located at this location in the computer's memory." When you look up a record from that result-set, PHP then knows where to look for the data. I never really use the "or die" syntax, I tend to explicitly check the return values of the functions. Try this: "; // need this to show output better in a HTML page var_dump($results_formatted); echo ""; // need this to show output better in a HTML page /* $results_formatted will then be set out like follows: $results_formatted[row_index][column_name] = column_value */ pg_close($db); ?> > Am I querying correctly? The table is "glossary_item", the row I want > is the one that is unique in containing the word "Alcohol" in the > column "name" > > I changed: $query = "SELECT * FROM glossary_item WHERE name= > 'Alcohol'"; > same result > > Picture me tearing out my hair... > Regards, Andy