Обсуждение: How to use Php connecting to pgsql

Поиск
Список
Период
Сортировка

How to use Php connecting to pgsql

От
马庆
Дата:
Dear All:
    I come across a problem that I can't solve it, Can anyone help me, Thanks.
    My configuration is RedHat AS4 + php5.0 + pgsql 8.1. When I finish install php, I install php_pgsql module in order
touse php connecting pgsql.  To my surprised , I can't get access to pgslq, there's nothing show on the page. 
    So I write <?php phpinfo() ?> it works.
    I write <?php echo "hello world" ? $db = pg_connect(dbname=foo, user=foo,password=foo); if(!$db) print("error")?> ,
itdoesn't work , only print "hello world" on the page. 
    But I use psql command with the same username and the same password, I can access to the pgsql.
    Does anybody know how to solve it? Thanks
MARK


Re: How to use Php connecting to pgsql

От
Ireneusz Pluta
Дата:
马庆 napisał(a):
> Dear All:
>     I come across a problem that I can't solve it, Can anyone help me, Thanks.
>     My configuration is RedHat AS4 + php5.0 + pgsql 8.1. When I finish install php, I install php_pgsql module in
orderto use php connecting pgsql.  To my surprised , I can't get access to pgslq, there's nothing show on the page. 
>     So I write <?php phpinfo() ?> it works.
>     I write <?php echo "hello world" ? $db = pg_connect(dbname=foo, user=foo,password=foo); if(!$db) print("error")?>
, 
shouldn't the connection string in pg_connect be quoted, like:
pg_connect("dbname=foo, user=foo,password=foo")
?
> it doesn't work , only print "hello world" on the page.
>
how do you test your script? If through http - check your http server
error log.
But generally, with such a basic test it is a far better idea to run a
test script from command line like:
php your_script.php
Then you can see all errors on your STDERR.
Make sure that error related parameters in your php.ini let you see
warnings and errors you want to see, or use an adequate ini_set() in
your script.
>     But I use psql command with the same username and the same password, I can access to the pgsql.
>     Does anybody know how to solve it? Thanks
> MARK
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org/
>
>
>
>
>
>



Re: How to use Php connecting to pgsql

От
"Raymond O'Donnell"
Дата:
On 30 Dec 2006 at 11:32,  wrote:

> nothing show on the page. So I write <?php phpinfo() ?> it works. I write

Did PostgreSQL support show up in the phpinfo() output? - there
should be a section entitled "pgsql". I've only used PHP on Windows,
but this might help point you in the right direction.

--Ray.


----------------------------------------------------------------------

Raymond O'Donnell
Director of Music, Galway Cathedral, Galway, Ireland
rod@iol.ie
----------------------------------------------------------------------