connection statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreenisha
    New Member
    • Aug 2008
    • 27

    connection statement

    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,p assword=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.
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    I think you use commas to separate all connections params, i'm not php specialist but maybe try to write connection string like that
    Code:
    pg_connect("host=localhost dbname=xxx password=xxx");
    Did you write connection string in that way?

    Comment

    • sreenisha
      New Member
      • Aug 2008
      • 27

      #3
      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

      Comment

      • rski
        Recognized Expert Contributor
        • Dec 2006
        • 700

        #4
        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.

        Comment

        • sreenisha
          New Member
          • Aug 2008
          • 27

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

          Comment

          • rski
            Recognized Expert Contributor
            • Dec 2006
            • 700

            #6
            Originally posted by sreenisha
            I cudnt find any postmaster log files.One folder pg_xlog is there which lists
            000000000000000 0
            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 .

            Comment

            • sreenisha
              New Member
              • Aug 2008
              • 27

              #7
              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

              Comment

              Working...