dbTalk Databases Forums  

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

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2364: DB Error: connect failed ... PHP/PostgreSql in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
manashi
 
Posts: n/a

Default [BUGS] BUG #2364: DB Error: connect failed ... PHP/PostgreSql - 03-30-2006 , 04:32 PM







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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Reply With Quote
  #2  
Old   
Richard Huxton
 
Posts: n/a

Default Re: [BUGS] BUG #2364: DB Error: connect failed ... PHP/PostgreSql - 04-03-2006 , 08:16 AM






manashi wrote:
Quote:
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
This is probably *not* a bug in PostgreSQL, and you'll be able to find
better help at the pgsql-general/pgsql-novice/pgsql-php mailing lists.

However...

Quote:
$dsn = "pgsql://$username:$password@$hostname/$dbname";
echo "The DSN : $dsn<br>";

$con = DB::connect($dsn);

The DSN : pgsql://root:@localhost/sample
The Connection Object : Object id #2
Error Number : 1
The Message : DB Error: connect failed

i hav tried a lot to find out the error but unable to find it
Well:
1. Are you logging connection attempts on the server-side and what does
it show?
2. Have you tried turning error verbosity up?
3. What does "psql -U root -h localhost sample" do for you?
4. Have you checked your pg_hba.conf file

It's almost certainly an issue with #4 - the pg_hba.conf file.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.