Обсуждение: Showing Database connection error through perl

Поиск
Список
Период
Сортировка

Showing Database connection error through perl

От
samik@cae.wisc.edu (Samik Raychaudhuri)
Дата:
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