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

Re: What's wrong with this? (Pt II)

From: info(at)i-developit(dot)com
To: John Poltorak <jp(at)eyup(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: What's wrong with this? (Pt II)
Date: 2001-01-22 12:03:30
Message-ID: 3A6C2192.7323598B@i-developit.com (view raw or flat)
Thread:
Lists: pgsql-novice
That's because the function should actually be,

pg_fetch_array(integer result, integer row)

When in doubt always check the php manual online
at www.php.net. As I said in an earlier e-mail on
this subject, I don't use the standard pgsql functions
within php, I use phpLIB.  Sorry for typing the wrong
function, but I was close :)


--Andy

John Poltorak wrote:
> 
> On Mon, Jan 22, 2001 at 04:40:34AM -0500, info(at)i-developit(dot)com wrote:
> > Don't forget too that when you do a pgsql_fetch_array,
> > the way your are doing it, it will only pull the last
> > item. You need to make that in a while loop, so that
> > it will retreive all the rows of data.
> 
> Yes, I am aware of that, but pulling any item appears to be proving a
> hurdle...
> 
> > Example:
> >
> > while($row = pgsql_fetch_array($result))
> > {
> >       echo $row["townName"];
> > }
> >
> > This will display all the townName entries that were a part
> > of your query. (i.e., if there were 4 results returned, it would
> > display all 4 results, but only the column townName)
> 
> It appears that there is something fundamentally wrong.
> 
> Here's the full script:-
> 
> <HTML>
> <HEAD>
> <TITLE>pg_test</TITLE>
> </HEAD>
> <BODY>
> 
> <?
> 
> $connectid = pg_connect("194.164.53.200", "5432", "postgres");
> 
> $query = "SELECT townName FROM towns";
> 
> $result = pg_exec($connectid, $query);
> 
> while($row = pgsql_fetch_array($result))
> {
>         echo $row["townName"];
>         }
> 
> ?>
> 
> This is the response:-
> 
> Fatal error: Call to undefined function: pgsql_fetch_array() in test.php
> on line 17
> 
> Line 17 => while($row = pgsql_fetch_array($result))
> 
> c:\>php  -v
> 4.0.4pl1
> 
> Since this appears to be a PHP problem rather than anything specific to
> Postges, I guess I should pursuit it elsewhwere. Is there anything like
> a PHP-Novices mailing list anywhere?
> 
> > Hope this helps,
> > Andy Holman
> 
> --
> John

In response to

pgsql-novice by date

Next:From: Ameurlain AntoineDate: 2001-01-22 17:05:50
Subject: per backend nofsync
Previous:From: John PoltorakDate: 2001-01-22 10:04:52
Subject: Re: What's wrong with this? (Pt II)

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