Connecting Tech Pros Worldwide Forums | Help | Site Map

connection statement

Newbie
 
Join Date: Aug 2008
Posts: 27
#1: Aug 19 '08
Hi
i am trying to connect postgres database using php.my database name is DB username=GPME and password=secret.I tried the pg_connect() using host=localhost parameter also.The following error occurs.

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Database "DB,user=GPME,password=secret" does not exist in the system catalog. . in /var/www/html/GPME/technical.php on line 3
Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource in /var/www/html/GPME/technical.php on line 10

My php version is 4.3.3 and pgsql version is 7.3.4.I tried this with mysql and it is working.Anyone please help me in this issue.

Moderator
 
Join Date: Dec 2006
Location: Europe
Posts: 293
#2: Aug 19 '08

re: connection statement


I think you use commas to separate all connections params, i'm not php specialist but maybe try to write connection string like that
Expand|Select|Wrap|Line Numbers
  1. pg_connect("host=localhost dbname=xxx password=xxx");
  2.  
Did you write connection string in that way?
Newbie
 
Join Date: Aug 2008
Posts: 27
#3: Aug 21 '08

re: connection statement


Ye,I tried that.I tried to edit the pg_hba.conf file and removed the comment on the line
host all all 127.0.0.1 255.255.255.255 trust

too and restarted the postmaster service.

But still warning is there :

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Missing or erroneous pg_hba.conf file, see postmaster log for details . in
Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource in /var/www/html/GPME/sample.php
Moderator
 
Join Date: Dec 2006
Location: Europe
Posts: 293
#4: Aug 21 '08

re: connection statement


Quote:

Originally Posted by sreenisha

Ye,I tried that.I tried to edit the pg_hba.conf file and removed the comment on the line
host all all 127.0.0.1 255.255.255.255 trust

too and restarted the postmaster service.

But still warning is there :

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Missing or erroneous pg_hba.conf file, see postmaster log for details . in
Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource in /var/www/html/GPME/sample.php

Oh, so you've got wrong pg_hba file. Look at it. Maybe there is somewere missing # (is a comment). Show here lines from pg_hba without leading #. Do you log events if so check postgres log.
Newbie
 
Join Date: Aug 2008
Posts: 27
#5: Aug 21 '08

re: connection statement


I cudnt find any postmaster log files.One folder pg_xlog is there which lists
0000000000000000
Shall we create a log file or does it come with POstgresql itself.
Moderator
 
Join Date: Dec 2006
Location: Europe
Posts: 293
#6: Aug 21 '08

re: connection statement


Quote:

Originally Posted by sreenisha

I cudnt find any postmaster log files.One folder pg_xlog is there which lists
0000000000000000
Shall we create a log file or does it come with POstgresql itself.

The place where log files are stored is defined in postgres.conf.
BTW what about not commented lines from pg_hba.conf .
Newbie
 
Join Date: Aug 2008
Posts: 27
#7: Aug 22 '08

re: connection statement


Here is my ph_hba.conf file entries which is not leading by a #.That is the last line of the configuration file.

local all all ident sameuser
Reply