CGI program cannot access database - Mailing list pgsql-general

From Samik Raychaudhuri
Subject CGI program cannot access database
Date
Msg-id 4165F78F.7070002@freeshell.org
Whole thread Raw
Responses Re: CGI program cannot access database  (Steven Klassen <sklassen@commandprompt.com>)
Re: CGI program cannot access database  (Samik Raychaudhuri <samik@freeshell.org>)
List pgsql-general
Hello,
I am trying to run a perl CGI program for accessing a database. The
program runs fine from command prompt, producing expected output. But it
gives errors while running as CGI.

--------- Program -------------
use DBI;
use DBD::Pg;
print "Content-type: text/plain\n\n";
$dbh=DBI->connect("dbi:Pg:dbname='samik';host='abc.org';port=5432","samik","xxxx");
$query="select * from temp";
$sth=$dbh->prepare($query);
$sth->execute ;
while(@data=$sth->fetchrow_array())
{       print $data[0].", ".$data[1]."<br>\n";        }
$sth->finish;
$dbh->disconnect();
-------------------------------------

This was giving me the following error:
DBI connect('dbname='samik';host='abc.org';port=5432','samik',...)
failed: could not translate host name "abc.org" to address: Unknown host
at /var/www/cgi-bin/test/dbex.pl line 6

When I replaced the host name with its IP address, I got the following
error:
DBI connect('dbname='samik';host='a.b.c.d';port=5432','samik',...)
failed: could not create socket: Operation not permitted at
/var/www/cgi-bin/test/dbex.pl line 6

Has anyone come across this problem before? Any pointers are welcome.
Thanks for your time and regards,
-Samik

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Index problem.... GIST (tsearch2)
Next
From: Tom Lane
Date:
Subject: Re: Index problem.... GIST (tsearch2)