RE: [PHP] How to connect to PostgreSQL with phpPgAdmi

From: Juan Ramón Cortabitarte <jcorta(at)tribctas(dot)gba(dot)gov(dot)ar>
To: "Paulo Parola" <pgsql(at)brazilinfo(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: RE: [PHP] How to connect to PostgreSQL with phpPgAdmi
Date: 2001-03-05 12:17:18
Message-ID: 002401c0a56e$38c20980$27012a0a@tribctas.gba.gov.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hi,
the only think you need to do is create a user(ej: phppgadmin) and grand permition (only select) to table pg_users. Then in the config.inc.php file you need to put:

$cfgServers[1]['local'] = false;
$cfgServers[1]['host'] = 'hostname;
$cfgServers[1]['port'] = '5432';
$cfgServers[1]['adv_auth'] = true;
$cfgServers[1]['stduser'] = 'phppgadmin';
$cfgServers[1]['stdpass'] = 'the password of the user phppgadmin';
$cfgServers[1]['user'] = '';
$cfgServers[1]['password'] = '';
$cfgServers[1]['only_db'] = ''; // if set to a db-name, only this db is accessible

no more.
it worked with postgres 7.02 and red hat 7.0

by
----- Original Message -----
From: Paulo Parola
To: pgsql-general(at)postgresql(dot)org
Sent: Sunday, March 04, 2001 9:40 PM
Subject: [GENERAL] [PHP] How to connect to PostgreSQL with phpPgAdmi

For the phpPgAdmin users, if you might help!!!....

I am running PostgreSQL 7.1 over RedHat.

When trying to connect through the web everything goes right. A script that is currently working:

<?php

$link = pg_Connect("host=localhost port=5432 dbname=teste")
or die ("Could not connect");

$comando = "select * from teste";
$result = pg_exec($link,$comando);
$linhas_retornadas = pg_numrows($result);

echo "<table><td><b>nome</b></td><td><b>sobrenome</b>";
for ($i=0; $i < $linhas_retornadas; $i++) {
$row=pg_fetch_array($result,$i);
echo "<tr><td>" . $row["nome"] . "</td>";
echo "<td>" . $row["sobrenome"] . "</td></tr>";
}
echo "</table>";

pg_close ($link);
?>

All *my databases are owned by user 'postgres'* and I had to create another PostgreSQL *user 'apache' and give ownership of table 'teste' in database 'teste' to this user* (apache) in order for this connection to work.

My 'pg_hba.conf' file reads:
local all trust
host all 127.0.0.1 255.255.255.255 trust

With phpPgAdmin I configured file 'config.inc.php' as follows:

// The default database is used to connect to the database to check the adv_auth
// This can actually be any database you currently have on your system. It just
// needs _a_ database to connect and check the system tables.
$cfgDefaultDB = "teste";

// You should change the superuser if different from postgres
// This is just used to filter out the system functions when listing
$cfgSuperUser = "postgres";

// Set to true if you want to authenticate against the passwd as well as the username
// In order to use adv_auth, you must update the passwords in the user admin section.
// It is suggested that you leave this as false until you are able to get in and update the passwords.
$cfgUsePass = false;
$cfgServers[1]['local'] = true;
$cfgServers[1]['host'] = 'localhost';
$cfgServers[1]['port'] = '5432';
$cfgServers[1]['adv_auth'] = false;
$cfgServers[1]['stduser'] = 'apache';

No matter if I set
$cfgServers[1]['host'] as 'localhost' or as '127.0.0.1'
$cfgServers[1]['stduser'] as 'apache' or as 'postgres' or as none

No matter what I always get a blank Web page with the following messages:

================
ERROR
The requested URL could not be retrieved

While trying to retrieve the URL: [no URL]

The following error was encountered:
Zero Sized Reply

Squid did not receive any data for this request.
Your cache administrator is webmaster.
Generated Sun, 04 Mar 2001 23:15:30 GMT by internet.gst.com.br (Squid/2.3.STABLE3)
================

The system tables in PostgreSQL are as follows:

teste=# select * from pg_user\g
usename | usesysid | usecreatedb | usetrace | usesuper | usecatupd | passwd | valuntil
----------+----------+-------------+----------+----------+-----------+----------+----------
postgres | 26 | t | t | t | t | ******** |
apache | 27 | f | f | f | f | ******** |
(2 rows)

teste=# select * from pg_shadow\g
usename | usesysid | usecreatedb | usetrace | usesuper | usecatupd | passwd | valuntil
----------+----------+-------------+----------+----------+-----------+--------+----------
postgres | 26 | t | t | t | t | |
apache | 27 | f | f | f | f | |
(2 rows)

Please help!!! This shall most probably be some problem of permission, but how do I manage to make phpPgAdmin to correctly connect and access my databases?

TIA,
Paulo

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martin A. Marques 2001-03-05 13:25:59 Re: INSERT ... RETURNING as Oracle
Previous Message Patrick Welche 2001-03-05 11:30:18 Re: Help with pq++