You need something like this:
$query = "select id, name from tablename";
$result = pg_query($query);
while ($row = pg_fetch_array($result)) {
$content = $row[0];
}
That's actually what I was using.
The scoping wasn't the issue either.
Today I switched back to pg_connect() from pg_pconnect(), made some
changes to my overall architecture and re-wrote my database stuff. Then
re-booted.
Not sure what fixed it but all working now. I'm only working on a draft
"skeleton" right now so am free to fiddle.
Keep finding cool features in PostgreSQL, I think I'm sold!
Thanks
Mick