Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0A7736504D5 for ; Wed, 30 Jul 2008 19:02:23 -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 83435-04-6 for ; Wed, 30 Jul 2008 19:02:15 -0300 (ADT) X-Greylist: delayed 00:31:45.336697 by SQLgrey-1.7.6 Received: from nathalia.gransy.com (nathalia.gransy.com [82.208.29.194]) by postgresql.org (Postfix) with ESMTP id 19E91650486 for ; Wed, 30 Jul 2008 19:02:12 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by nathalia.gransy.com (Postfix) with ESMTP id 774C97AC0DE; Wed, 30 Jul 2008 23:42:39 +0200 (CEST) Received: from nathalia.gransy.com ([127.0.0.1]) by localhost (nathalia.gransy.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OeYOGY2vghHI; Wed, 30 Jul 2008 23:42:39 +0200 (CEST) Received: from [192.168.1.1] (ip-89-102-139-23.karneval.cz [89.102.139.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by nathalia.gransy.com (Postfix) with ESMTP id 481A07AC0B4; Wed, 30 Jul 2008 23:42:39 +0200 (CEST) Message-ID: <4890DE46.9020208@fuzzy.cz> Date: Wed, 30 Jul 2008 23:33:58 +0200 From: Tomas Vondra User-Agent: Thunderbird 2.0.0.9 (X11/20080213) 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/14 X-Sequence-Number: 3878 > 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: > > $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'"; > $results = pg_query($db, $query) or die("Error in query: $query. > " . pg_last_error($db)); > var_dump ($results); > $val = pg_fetch_result($results, 1, 3); > echo $val, "\n"; > pg_close($db); > ?> > > 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* > 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. > 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... Have you tried running the query from psql (or any other SQL interface)? This warning means there are no rows in the result, so it can't skip to the second row in it (the first row has index 0). Tomas