Midnite has asked for the wisdom of the Perl Monks concerning the following question:

Oh glorious Monks,

I seek wisdom on a script I am working on. I keep getting a 500 Internal Server Error, and it is a very strange error I get from the error_log:

[Tue Aug 10 13:59:26 2004] [error] [client 216.125.160.51] malformed header from script. Bad header=<BODY BGCOLOR="#FFFFFF"><font : /usr/local/httpd/virtuals/elghome/www.elginarea.org/cgi-bin/make2.pl

The code it is bombing on is:

print "Content-type: text/html\n"; #print "<TITLE>B.O.B. Question</TITLE>\n"; print "<BODY BGCOLOR=\"#FFFFFF\"><font face=\"Arial\" size=\"3\">\n";

If I didn't comment out the title, it would have bombed there. I have been working on this for days, and I have no resolution. It does what I want, but I need to print out a web confirmation page based on the data.

Your wisdom would be greatly appreciated. If you need anymore code, just ask.

Joseph A. Ruffino
Automated Systems Assistant
Gail Borden Public Library District
270 N. Grove Ave
Elgin, Il, 60120
847-742-2411 x5986

20040811 Janitored by Corion: Put code tags around error message and code, retitled from "Bad Header"

Replies are listed 'Best First'.
Re: Bad Header
by Aristotle (Chancellor) on Aug 10, 2004 at 19:08 UTC

    You need to add a second newline after the headers, as in

    print "Content-type: text/html\n\n";

    You may want to keep Troubleshooting Perl CGI scripts in mind next time you run into a problem.

    Makeshifts last the longest.

      I am sooo embarrased. I should have known that.

      Thank You Aristotle

      Joseph A. Ruffino
      Automated Systems Assistant
      Gail Borden Public Library District
      270 N. Grove Ave
      Elgin, Il, 60120
      847-742-2411 x5986
Re: Bad Header
by dragonchild (Archbishop) on Aug 10, 2004 at 19:10 UTC
    This is a textbook example of why you should use modules like CGI and/or CGI::Application when developing web applications. It's a lot easier to remember print $cgi->header; than to remember what the header actually is.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested