how to retrieve data from postgresql database

From: Sudheer Raghav (yelukur_at_yahoo.com)
Date: 01/28/05


Date: Thu, 27 Jan 2005 21:51:34 -0800 (PST)
To: sdavis2@mail.nih.gov, sam.wun@authtec.com, Jcuson@isdh.state.in.us

hi ,
  
   am new to perl. plz help me with the following:
  
   1.How to reteive records from postgresql databasse
using PERL?
 here is my code follows:
  #!/usr/bin/perl
 print "Content-type: text/html\n\n";

 use CGI;

 use DBI;
 my ($dbh, $sth, @array_ref, $ip_add, $sql);
 $dbh =
DBI->connect('dbi:Pg:dbname=test','postgres','');

 print <<HTML;
 <center>FIREWALL</center>
 <P><b>IP Address</b>
 &nbsp;&nbsp;<select name="$ip_add" style="12"
vertical-align:baseline>

 $sql = qq{SELECT * FROM firewall};
 $sth = $dbh->prepare($sql);
 $sth->execute();
my $array_ref = $sth->fetchall_arrayref();
 foreach my $row (@$array_ref[0 .. 20]) {
  $ip_add = $array_ref[0];
<option>$ip_add</option>
}
$sth->finish();
/select>

&nbsp;&nbsp;<b>Source Address</b>
&nbsp;&nbsp;<INPUT TYPE="text" NAME="$source_add"
SIZE="12" MAXLENGTH="12">
&nbsp;&nbsp;&nbsp;<b>Destination Address</b>
&nbsp;&nbsp;<INPUT TYPE="text" NAME="$Dest_add"
SIZE="12" MAXLENGTH="12" >
&nbsp;&nbsp;&nbsp;<b>Enable</b>
&nbsp;&nbsp;<INPUT TYPE="radio" NAME="$enable"
value="active" >
&nbsp;&nbsp;&nbsp;<b>Disable</b>
&nbsp;&nbsp;<INPUT TYPE="radio" NAME="$Disable"
value="suspend" >
</P>
<center><INPUT TYPE="submit" NAME="submit"
VALUE="save">
<INPUT TYPE="submit" NAME="cancel"
VALUE="Cancel"></center>
HTML

  $dbh->disconnect();

exit;
  

   my dbname : test
       table : firewall which conains ip_add column
       username : postgres
Aim of this project:
   How to fetch / retrieve records from table in
postgresql database using PERL and then i need to save
the contents in text file.

Error Occured:
    when am running this program with command perl
dh.pl it is working fine.But whenever i run it on web
browser it is not retrieving records from database.
  
   Plz help me in this regard.........

                
__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
 



Relevant Pages

  • Bot::BasicBots forkit() creating zombies
    ... First of all I'd like to tell you all that I'm a total Perl newbie, ... Bot::BasicBot's forkit() method to run for example a Yahoo! ... my $message = shift; ...
    (comp.lang.perl.misc)
  • Summary: array in ksh
    ... IFS environment variable to a newline. ... Ilhan Narili ... Some suggested that I use perl. ... Do you Yahoo!? ...
    (SunManagers)
  • Re: is there the simplest way to do this: logon to my email account and delete bulk emails?
    ... Google search along the lines of "CPAN yahoo mail". ... you could indeed get the job done with a few lines of Perl. ... this newsgroup was a perfectly good forum for sketching ...
    (comp.lang.perl.misc)
  • Re: perl
    ... I am sure about it shows very clear in error message The system cannot find the path ... Subject: perl ... I am using apache 2.0.04 win32 version in window XP, ... Have a HUGE year through Yahoo! ...
    (perl.beginners)
  • Re: how to print " time " ???
    ... I wonder why perldoc works on my installation of Activestate perl when it ... > Do You Yahoo!? ... Mail has the best spam protection around ...
    (perl.beginners)