Showing Database connection error through perl - Mailing list pgsql-general

From samik@cae.wisc.edu (Samik Raychaudhuri)
Subject Showing Database connection error through perl
Date
Msg-id fbf5e750.0202111840.39545d29@posting.google.com
Whole thread Raw
List pgsql-general
Hello,
I have got a problem regarding showing my database connection errors
through CGI program. I have got the following lines of code:
---------------------------------------------
#!/s/std/bin/perl
use lib "/s/postgresql-7/perl5";
use DBI;

$dbh=DBI->connect("dbi:Pg:dbname='src';host='...';port=5432","sam","")
|| die "Content-type: text/plain\n\nCouldn't connect to
DB: ".DBI::errstr. " and something.\n";

----------------------------------------------

When I run the program from the command prompt, and if it can't
connect to the database, it shows the reason of the error, as shown
below:

----OUTPUT---------------
DBI->connect failed: FATAL 1:  user "sam" does not exist at dbex.pl
line 8
Content-type: text/plain

Couldn't connect to DB: FATAL 1:  user "sam" does not exist and
something.
-----------------

But when I try to run the same program through web-browser, it
(web-log) doesn't show the error string. The output I get is:

----OUTPUT----
DBI->connect failed: 1 at /var/home/www/cgi-public/samik/test/dbex.pl
line 8
Content-type: text/plain

Couldn't connect to DB: 1 and something.
------------------

Can anyone suggest what might be the error, or what I should do to get
the full error string through the browser/web-log.
Thanks and regards.
-Samik

pgsql-general by date:

Previous
From: Rich Shepard
Date:
Subject: Re: 7.2 PGDG RPMS and readline 4.0
Next
From: Lamar Owen
Date:
Subject: Re: postgresql -- what's in a name?