Hello!
I have a strange thing going on. This is my perl code:
______________________________________
#! /usr/bin/perl
use CGI;
use DBI;
print "Content-type: text/html\n\n";
print "<HTML><HEAD><meta http-equiv=Content-Type content=text/html; charset=iso-8859-2><TITLE> Adding a NIC card name</TITLE></HEAD>";
print "<BODY BGCOLOR=EEEEEE>";
$username = 'root';$password = '';$database = 'arp';$hostname = '';
$dbh = DBI->connect("dbi:mysql:database=$database;" .
"host=$hostname;port=3306", $username, );
my $q=new CGI;
$MAC=$q->param("id");
#print "MAC: $MAC\n";
print "<HR>";
print "<H2><B><font color=\"#800000\"> All data about $MAC </font></B></H2>";
#creating HTML table
print "<BR><BR>";
print "<TABLE ALIGN=center WIDTH=50% BORDER=4 CELLSPACING=2 CELLPADDING=2>";
print "<tr> <th align=center valign=middle> MAC </th>";
print "<th align=center valign=middle> NIC name </th>";
print "<th align=center valign=middle> Computer name /th>";
print "<th align=center valign=middle> IP </th>";
print "<td align=center valign=middle> date </td>";
print "<td align=center valign=middle> time </td>";
print "</tr>";
$SQL="select * from table where MAC='$MAC' order by date";
$Select = $dbh->prepare($SQL);
$Select->execute();
while($Row=$Select->fetchrow_hashref)
{
print "<tr><td>$Row->{MAC} </a> <td>$Row->{NICname} <td>$Row->{CompName} <td>$Row->{IP} <td>$Row->{date} <td>$Row->{time}</tr>";
$mac1=$Row->{MAC};
$nameMAC=$Row->{NICname};
}
print "</TABLE>";
if ($NICname eq '')
{
print "<FORM action=\"/cgi-bin/NICname.pl\" method=post>";
print "<input type=text size=20 name=\"name\">";
print "<INPUT TYPE=submit NAME=submit value=\"Save\">";
print "</FORM>";
}
print "</BODY></HTML>";
______________________________________
When I check it from command line:
perl -wc myscript.pl
it says everything's ok.
But when I run it as html, I get Internal Server Error. And in Error_log file it says: malformed header from script. Bad header=name=myNIC&submit=Save: ...
Any ideas why this is happening and how to fix it?
I have a strange thing going on. This is my perl code:
______________________________________
#! /usr/bin/perl
use CGI;
use DBI;
print "Content-type: text/html\n\n";
print "<HTML><HEAD><meta http-equiv=Content-Type content=text/html; charset=iso-8859-2><TITLE> Adding a NIC card name</TITLE></HEAD>";
print "<BODY BGCOLOR=EEEEEE>";
$username = 'root';$password = '';$database = 'arp';$hostname = '';
$dbh = DBI->connect("dbi:mysql:database=$database;" .
"host=$hostname;port=3306", $username, );
my $q=new CGI;
$MAC=$q->param("id");
#print "MAC: $MAC\n";
print "<HR>";
print "<H2><B><font color=\"#800000\"> All data about $MAC </font></B></H2>";
#creating HTML table
print "<BR><BR>";
print "<TABLE ALIGN=center WIDTH=50% BORDER=4 CELLSPACING=2 CELLPADDING=2>";
print "<tr> <th align=center valign=middle> MAC </th>";
print "<th align=center valign=middle> NIC name </th>";
print "<th align=center valign=middle> Computer name /th>";
print "<th align=center valign=middle> IP </th>";
print "<td align=center valign=middle> date </td>";
print "<td align=center valign=middle> time </td>";
print "</tr>";
$SQL="select * from table where MAC='$MAC' order by date";
$Select = $dbh->prepare($SQL);
$Select->execute();
while($Row=$Select->fetchrow_hashref)
{
print "<tr><td>$Row->{MAC} </a> <td>$Row->{NICname} <td>$Row->{CompName} <td>$Row->{IP} <td>$Row->{date} <td>$Row->{time}</tr>";
$mac1=$Row->{MAC};
$nameMAC=$Row->{NICname};
}
print "</TABLE>";
if ($NICname eq '')
{
print "<FORM action=\"/cgi-bin/NICname.pl\" method=post>";
print "<input type=text size=20 name=\"name\">";
print "<INPUT TYPE=submit NAME=submit value=\"Save\">";
print "</FORM>";
}
print "</BODY></HTML>";
______________________________________
When I check it from command line:
perl -wc myscript.pl
it says everything's ok.
But when I run it as html, I get Internal Server Error. And in Error_log file it says: malformed header from script. Bad header=name=myNIC&submit=Save: ...
Any ideas why this is happening and how to fix it?