I have just installed postgresql 8 on my RHEL 3.0 Update 4 system. Everything seems to be working, all my data is there I can connect using Perl/DBI and psql etc. . . then I try my PHP page, that works just fine with PostgreSQL 7, and I get the message -- DB Error: no such database. Nothing appears in the log files that I am familar with. Again, this code works currently against prior version of PostgreSQL without issue.

I am running RHEL 3.0 with all of its standard software. I have added nothing nor tweaked anything. I even installed PostgreSQL 8 from RPMs for rhel-3.0.

<?php
   function MyDbConnect() {
      $dsn = array(
         'phptype'      => 'pgsql',
         'username'     => 'user',
         'password'     => '',
         'hostspec'     => 'localhost',
         'port'         => '5432',
         'database'     => 'SERVER_MGMT',
      );

   $options = array(
      'debug'           => '2',
      );

   $db = DB::connect($dsn, $options);

   return $db;
   }
?>

Given the new features of 8 I would very much like to upgrade to it; however, can not until I figure out this issue. Any help is greatly appreciated. -Thanks

    Originally posted by sammon96

    <?php
       function MyDbConnect() {
          $dsn = array(
             'phptype'      => 'pgsql',
             'username'     => 'user',
             'password'     => '',
             'hostspec'     => 'localhost',
             'port'         => '5432',
             'database'     => 'SERVER_MGMT',
          );
    
       $options = array(
          'debug'           => '2',
          );
    
       $db = DB::connect($dsn, $options);
    
       return $db;
       }
    ?>

    [/B]

    Is the database really UPPER CASE named SERVER_MGMT?

    If so, you might need to quote it:

             'database'     => '"SERVER_MGMT"',
    

      Made the suggested change with no luck...

         function MyDbConnect() {
            $dsn = array(
               'phptype'      => 'pgsql',
               'username'     => 'syslog',
               'password'     => '',
               'hostspec'     => 'localhost',
               'port'         => '5432',
               'database'     => '"SERVER_MGMT"',
            );
      
         $options = array(
            'debug'           => 2,
            );
      
         $db = DB::connect($dsn, $options);
      
         return $db;
         }
      ?>
      

      Still see the same problem. Also, to be certain I am not running an RC version of PGSQL 8. I have the actual release that came out this week, 8.0.0

        So, is the database named UPPER CASE like this?

          The database name is uppercase...

          psql -U user -d SERVER_MGMT
          Welcome to psql 8.0.0, the PostgreSQL interactive terminal.

          Type: \copyright for distribution terms
          \h for help with SQL commands
          \? for help with psql commands
          \g or terminate with semicolon to execute query
          \q to quit

          SERVER_MGMT=>

            Hi,

            Just a shot in the dark but check if everything is ok with the pgsql PHP extension. Create a phpinfo() script and check if the output contains a PostgreSQL section.

            Depending on the version of the DB library a wrong error message might be displayed (there was a bug in some versions).

            Thomas

              Are you sure this isn't a problem with PostgreSQL configuration, like tcpip_sockets bein false, or pg_hba.conf not having an entry for your web server machine?

                It turns out that by looking at phpinfo a little more careful and comparing /etc/php.d on my prod server running PGSQL 7.x to that of my test system I found I was missing the RedHat package php-pgsql. Once I installed that and the /etc/php.d/pgsql.ini file came to be everything worked.

                Thank you all!

                  Write a Reply...