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
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html