freelanceprogrammers.org Forum Index » Perl
problem with my perl cgi code
Joined: 29 Jun 2005
Posts: 1
problem with my perl cgi code
Hi all,
I have written a perl cgi code which fetches the some data from data base
and prints on to browser.
When I tried to run the script directly from console, its printing the html
code.. But when I tried to run from the browser its displaying blank page (
in page source I could see html code till body tag )..
what could be the problem. I`m sending the code that I`ve written
#!/usr/local/bin/perl
use CGI;
use DBI;
my $dbh = DBI -> connect("DBI:Oracle:oracle","training","training");
my $cgi = new CGI;
print $cgi -> header;
print $cgi -> start_html( -title => `details`,
-author => `srinu`);
my $empno = $cgi -> param(`empno`);
my $ename = $cgi -> param(`ename`);
my $job = $cgi -> param(`job`);
my $mgr = $cgi -> param(`mgr`);
my $date =
$cgi->param(`day`)."-".$cgi->param(`mon`)."-".$cgi->param(`year`);
my $sal = $cgi ->param(`sal`);
my $comm = $cgi -> param(`comm`);
my $deptno = $cgi -> param(`deptno`);
my $click = $cgi -> param(`click`);
if($click eq "Submit") {
if ( $empno < 7000 || $empno > 9999) {
print "Invalid Employee Number<BR>";
exit;
}
else {
$sql = "insert into EMP2 values($empno,`$ename`,`$job`,
$mgr,`$date`,$sal,$comm,$deptno)";
$dbh -> do($sql);
print "Record updated<BR>
<a href=emp.cgi>Back to Report</a>";
}
}
if($click eq "ViewDetails!") {
$sql = "select * from EMP2";
$sth = $dbh -> prepare($sql);
$sth -> execute();
print "<h1>Employee Details</h1><BR><BR>";
print "<table border =1>";
while (@k = $sth -> fetchrow_array()) {
print "
<tr>";
for($i = 0; $i < @k;$i++) {
print"<td>$k[$i]</td>";
}
print "
</tr>";
}
print "</table>";
print "<BR><a href=emp.cgi>Back to Report</a>";
$sth -> finish;
}
$dbh -> disconnect;
print $cgi -> end_html();
ps: If I`m not clear with the code or question and please let me know.
--
Thanks,
Srinivas..
[Non-text portions of this message have been removed]
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







