From: Tomas Vondra <tv@fuzzy.cz>
To: PJ <af.gourmet@videotron.ca>
Cc: Lynna Landstreet <lynna@spidersilk.net>
Cc: pgsql-php@postgresql.org
Subject: Re: display query results
Date: Wed, 30 Jul 2008 23:33:58 +0200
Message-ID: <4890DE46.9020208@fuzzy.cz> (raw)
In-Reply-To: <4890CA07.2040405@videotron.ca>
References: <48909454.7040305@videotron.ca>
<82E74D266CB9B44390D3CCE44A781ED90B64DC@POSTOFFICE.cranel.local>
<4890A871.3020906@videotron.ca>
<4890AA8C.9080907@spidersilk.net>
<4890CA07.2040405@videotron.ca>
> 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:
>
> <?php
> $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
> <http://biggie/k2/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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: tv@fuzzy.cz, af.gourmet@videotron.ca, lynna@spidersilk.net
Subject: Re: display query results
In-Reply-To: <4890DE46.9020208@fuzzy.cz>
References: <48909454.7040305@videotron.ca> <82E74D266CB9B44390D3CCE44A781ED90B64DC@POSTOFFICE.cranel.local> <4890A871.3020906@videotron.ca> <4890AA8C.9080907@spidersilk.net> <4890CA07.2040405@videotron.ca> <4890DE46.9020208@fuzzy.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox