The following bug has been logged online:
Bug reference: 2364
Logged by: manashi
Email address: manashi_130582@rediffmail.com
PostgreSQL version: psql (PostgreSQ
Operating system: Linux
Description: DB Error: connect failed ... PHP/PostgreSql
Details:
hi...
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
and
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 :-
<?php
include("DB.php");
$username = "root";
$password = "";
$hostname = "localhost";
$dbname = "sample";
$dsn = "pgsql://$username:$password@$hostname/$dbname";
echo "The DSN : $dsn<br>";
$con = DB::connect($dsn);
echo "The Connection Object : $con<br>";
if(DB::isError($con))
{
$valu = DB::isError($con);
echo "Error Number : $valu <br>";
$val1 = $con->getMessage($valu);
echo "The Message : $val1<br>";
}
else
{
echo "Connection established <br>";
}
$sql="SELECT id,name FROM login";
echo "$sql<br>";
echo "$rs = $con->query($sql);";
echo "$rs<br>";
if(DB::isError($rs))
{
die($rs->getMessage());
}
while($row = $rs->fetchRow(DB_FETCHMODE_ASSOC))
{
$fulid = $row['id']." ";
$fulname = $row['name']." ";
echo "Details : $fulid $fulname<br>";
}
$con->disconnect();
?>
i created a directory name example in /var/www/html
and saved show.php there....
when i am executing this file as
http://localhost/example/show.php
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...