For Programmers: Free Programming Magazines  


Home > Archive > PHP Installation > April 2004 > Re: [PHP-INSTALL] pear db : can't connect to postgresql









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-INSTALL] pear db : can't connect to postgresql
Gabriel De Rezende E Lamounier

2004-04-27, 8:50 am

Em Seg 26 Abr 2004 16:03, Gabriel de Rezende e Lamounier escreveu:
> i have pear set up on my include_path.
> postgresql is running and i'm able to connect and query it using
> pg_connect() and pg_query().
> i can't conect to pgsql using pear db. here's the script:
>
> <html>
> <body>
> <?php
> require_once("DB.php");
>
> $dsn = "pgsql://postgres/teste";
> $db = DB::connect($dsn);
>
> if (DB::isError($db))
> {
> die($db->getMessage());
> }
>
> $db->disconect();
> ?>
> </body>
> </html>
>
> error message on the browser:
>
> DB Error: connect failed
>
> it's just a test server, the postgres user dosn't have a password set.
> using the native pgsql functions i connect like this:
>
> $db = pg_connect("dbname=teste user=postgres");
>
> any idea?


the intereting thing is that i can connect using the following syntax:

<html>
<body>
<?php
require_once("DB.php");

$dsn = array(
'phptype' => "pgsql",
'hostspec' => "",
'database' => "teste",
'username' => "postgres",
'password' => ""
);

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

if (DB::isError($db))
{
die($db->getMessage());
}

$db->disconnect();
?>
</body>
</html>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com