Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D47CD650308 for ; Wed, 30 Jul 2008 17:07:33 -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 76454-06 for ; Wed, 30 Jul 2008 17:07:26 -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 2F4F2650311 for ; Wed, 30 Jul 2008 17:07:29 -0300 (ADT) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=UTF-8; format=flowed Received: from [192.168.0.51] ([96.21.103.185]) by VL-MH-MR001.ip.videotron.ca (Sun Java(tm) System Messaging Server 6.3-4.01 (built Aug 3 2007; 32bit)) with ESMTP id <0K4U0002I58FEKB1@VL-MH-MR001.ip.videotron.ca> for pgsql-php@postgresql.org; Wed, 30 Jul 2008 16:07:28 -0400 (EDT) Message-id: <4890CA07.2040405@videotron.ca> Date: Wed, 30 Jul 2008 16:07:35 -0400 From: PJ User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) To: Lynna Landstreet Cc: 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> In-reply-to: <4890AA8C.9080907@spidersilk.net> 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/8 X-Sequence-Number: 3872 Lynna Landstreet wrote: > PJ wrote: >> 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 > > You can't print the results of a query directly - the format they are > retrieved in is not just a regular PHP array. That's what the various > "fetch" options do - they pull the data out of the resultset into a > regular variable (single or array, depending on which one you use) so > that you can print it or otherwise treat it as a normal variable. > > pg_fetch_result fetches a single value (string, integer, whatever it > might be) and stores it in a variable. You have to tell it exactly > which row and column from the result set you want. If you're only > after one value, use this. > > pg_fetch_array and pg_fetch_assoc each fetch a whole row of data, as > an array. The different between them is that with the first one, the > array keys are just numbers, and with the second, it's an associative > array where the keys are the names of the columns in your database. If > you've only retrieved one row, but need more than one value from that > row, use one of these. > > pg_fetch_all fetches *all* the rows from your result set, as a > multidimensional array. If your query is likely to have retrieved > multiple rows, use this. > > Does that help? 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* 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...