CGI program cannot access database

From: Samik Raychaudhuri <samik(at)freeshell(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: CGI program cannot access database
Date: 2004-10-08 02:12:31
Message-ID: 4165F78F.7070002@freeshell.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Jowett 2004-10-08 02:13:06 Fix setArray() when using the v3 protocol (was Re: Postgres 8.0 + JDBC)
Previous Message Tom Lane 2004-10-08 02:09:54 Re: Index problem.... GIST (tsearch2)