Author Topic: [Help] PHP Postgres Running  (Read 1554 times)

xtra

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
[Help] PHP Postgres Running
« on: March 04, 2008, 05:13:57 AM »
I have installed php5, apache2 and postgresql supported on centos5
i try to connect to my database using pg_connect as

Code: [Select]
       $constr="host=localhost port=5432 dbname=$DataBaseName user=$UserName password=$UserPassword";
$con = pg_connect($constr);

I can running through php(in shell mode) command is success(value of $con not false) but $con is aways return false with run through apache (open website).

Any one help me what is wrong

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: [Help] PHP Postgres Running
« Reply #1 on: March 04, 2008, 06:28:44 AM »
Does your script return any warnings when run with error_reporting(E_ALL); at the top? It sounds like the module is not loaded.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.

xtra

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: [Help] PHP Postgres Running
« Reply #2 on: March 04, 2008, 10:47:46 AM »
No anythings returned.  :o

xtra

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: [Help] PHP Postgres Running
« Reply #3 on: March 04, 2008, 10:58:29 AM »
Oh i turned it off.
now I switch it on.
i got error
Code: [Select]
Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running on host "localhost" and accepting TCP/IP connections on port 5432? in /home/user/public_html/testdb.php on line 2

My server already installed PostgreSQL server and open for accept port 5432  :cry:  :cry:

Code: [Select]
But i edited my php code and remove host address and port and run again Success to connect Local database.

But My Objective try to connect another host any one can tell me please.   :roll:  :roll:

PS. My target host was config pg_hba.conf accept my host.
PS.II I test code in my PC was success connect to target host but this host still contain error.  :cry:  :cry:  :cry:  :cry:

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: [Help] PHP Postgres Running
« Reply #4 on: March 05, 2008, 04:53:40 AM »
Code: [Select]
could not connect to server: Permission denied
Is PostgreSQL configured to accept incoming connections from your machine on your username?
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.