By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,745 Members | 1,897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,745 IT Pros & Developers. It's quick & easy.

connection statement

P: 27
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.
Aug 19 '08 #1
Share this Question
Share on Google+
6 Replies


Expert 100+
P: 700
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?
Aug 19 '08 #2

P: 27
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
Aug 21 '08 #3

Expert 100+
P: 700
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.
Aug 21 '08 #4

P: 27
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.
Aug 21 '08 #5

Expert 100+
P: 700
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 .
Aug 21 '08 #6

P: 27
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
Aug 22 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.