how to retrieve data from postgresql database
From: Sudheer Raghav (yelukur_at_yahoo.com)
Date: 01/28/05
- Next message: Ron Reidy: "RE: no rows selected"
- Previous message: Ing . Branislav Gerzo: "Re: get one column"
- Next in thread: Michael A Chase tech: "Re: how to retrieve data from postgresql database"
- Reply: Michael A Chase tech: "Re: how to retrieve data from postgresql database"
- Reply: Sean Davis: "Re: how to retrieve data from postgresql database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
<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>
<b>Source Address</b>
<INPUT TYPE="text" NAME="$source_add"
SIZE="12" MAXLENGTH="12">
<b>Destination Address</b>
<INPUT TYPE="text" NAME="$Dest_add"
SIZE="12" MAXLENGTH="12" >
<b>Enable</b>
<INPUT TYPE="radio" NAME="$enable"
value="active" >
<b>Disable</b>
<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
- Next message: Ron Reidy: "RE: no rows selected"
- Previous message: Ing . Branislav Gerzo: "Re: get one column"
- Next in thread: Michael A Chase tech: "Re: how to retrieve data from postgresql database"
- Reply: Michael A Chase tech: "Re: how to retrieve data from postgresql database"
- Reply: Sean Davis: "Re: how to retrieve data from postgresql database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|