Skip site navigation (1) Skip section navigation (2)

BUG #2364: DB Error: connect failed ... PHP/PostgreSql

From: "manashi" <manashi_130582(at)rediffmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2364: DB Error: connect failed ... PHP/PostgreSql
Date: 2006-03-30 13:08:20
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      2364
Logged by:          manashi
Email address:      manashi_130582(at)rediffmail(dot)com
PostgreSQL version: psql (PostgreSQ
Operating system:   Linux
Description:        DB Error: connect failed ... PHP/PostgreSql

     I am working on PHP using postgreSQl as DB...
  Both r very new to me....
  i logged in as root and
    created a user root 
    the command i hav used : createuser root      
    database sample : createdb sample
then to check list of database i used command : psql -l
    the  RESULT was

      List of databases
   Name    |  Owner   | Encoding
 sample    | root     | UNICODE
 template0 | postgres | UNICODE
 template1 | postgres | UNICODE
(3 rows)

  then i created a table in DB sample name "login"

 using normal sql query and inserted two datas

i created file "show.php" to display the content on web page
     the code is as follows :-


$username = "root";
$password = "";
$hostname = "localhost";
$dbname = "sample";

$dsn = "pgsql://$username:$password(at)$hostname/$dbname";
echo "The DSN : $dsn<br>";

$con = DB::connect($dsn);
echo "The Connection Object : $con<br>";

  $valu = DB::isError($con);
  echo "Error Number : $valu <br>";

  $val1 = $con->getMessage($valu);
  echo "The Message : $val1<br>";
  echo "Connection established <br>";

$sql="SELECT id,name FROM login";
echo "$sql<br>";

echo "$rs = $con->query($sql);";
echo "$rs<br>";


while($row = $rs->fetchRow(DB_FETCHMODE_ASSOC))
  $fulid = $row['id']." ";
  $fulname = $row['name']." ";
  echo "Details : $fulid $fulname<br>";

i created a directory name example in /var/www/html
   and saved show.php there....
    when i am executing this file as 

its displaying :

The DSN : pgsql://root:@localhost/sample
The Connection Object : Object id #2
Error Number : 1
The Message : DB Error: connect failed
SQL QUERY : SELECT id,name FROM login

i hav tried a lot to find out the error but unable to find it

 PostgreSQL version installed in my system :
  psql (PostgreSQL) 8.0.3
contains support for command-line editing

PHP version installed in my system :
PHP 5.0.4 (cli) (built: May  9 2005 11:21:11)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies

Operating System : LINUX

 Waiting for the REply...


pgsql-bugs by date

Next:From: Bujic NikolaDate: 2006-03-31 09:19:58
Subject: BUG #2365: can't install
Previous:From: Magnus HaganderDate: 2006-03-29 17:51:11
Subject: Re: BUG #2363: password authentication failed

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group