Thread: Failure to connect to database using php.

Failure to connect to database using php.

From
Vivek Sonny Abraham
Date:
Hi,

I am using the following code to connect to my database.

<?

$db = pg_connect("dbname=friends");
echo pg_dbname();

?>

But there is nothing  displayed on the screen when I try it on my browser.

I use apache 4.3.9, redhat and postgresql 7.4.6. What am I doing wrong?

Re: Failure to connect to database using php.

From
Volkan YAZICI
Date:
Hi,

On 6/28/05, Vivek Sonny Abraham <vivek.sonny.abraham@gmail.com> wrote:
> <?
>
> $db = pg_connect("dbname=friends");

Are you sure above line finishes succesfully?
Please try something with more verbosity like this:

<?php
    error_reporting(E_ALL);
    $conn = pg_connect("...") or die("Database connection failed!");
    ...
?>

For more information about handling pg_connect() errors, you can take
a look at http://php.net/pg_connect and comments related to it.

Regards.