PDA

View Full Version : Premature end of script headers:


drea900
05-02-2003, 10:39 PM
Hello I am having a hard time with this error message. I have uploading in ascii mode, chmod, and everything. Can anyone see why this code is giving me the Premature end of script headers: error in my servers error log.


#!/usr/bin/perl


use DBI;


print "Content-Type: text/html\015\012\015\012";


$dbh = DBI->connect
DBI->connect("DBI:mysql:drea900_mailinglist:localhost","username","password") or
dienice("Can not connect: ",$dbh->errstr);

$fname=param('fname');
$lname=param('lname');
$email=param('email');

$sth=$dbh=>prepare("INSERT INTO Cust_Info VALUES('$fname','$lname','$email'));
$sth->execute;
$sth->finish;

print<<pa
<body><h2>Hello $fname, <br></h2>
<h3>Your information has been recorded as follows: <p>
First Name: $fname<br>
Last Name: $lname<br>
Email Address: $email<br>
pa;

sub dienice {
($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}

chrisvmarle
05-03-2003, 01:53 AM
Try changing this:
print "Content-Type: text/html\015\012\015\012";

to this:
print "Content-Type: text/html\n\n";

Mzzl, Chris

Grant Palin
05-03-2003, 04:03 AM
Originally posted by chrisvmarle
Try changing this:
print "Content-Type: text/html\015\012\015\012";

to this:
print "Content-Type: text/html\n\n";

Mzzl, Chris

That's right, having anything other than "Content-Type: text/html\n\n"; will result in an end or header error. It must be as shown, otherwise it won't work.