in reply to Malformed HTML output

You haven't really given me much to go on, so I can't tell you how to fix it, but I can tell you how you might start going about debugging it... Try invoking your cgi script from the command line, manually feeding it values, and looking at all the stuff that comes back, HTTP headers included. To do this, you'll want to instantiate a CGI object with a file handle to a file that contains field value pairs, or with STDIN and type in the values when you run the script.

use CGI; open(FILE, "<data.txt") or die "gah!"; my $query = CGI->new(FILE);

Where data.txt contains stuff like...

foo=bar baz=biz

This cuts your web server and the browser out of the loop, isolating your debugging just to your script. Make sure that your HTTP headers are coming out looking alright, specifically checking to see that your headers and HTML body are separated by a blank line.

Replies are listed 'Best First'.
Re: Re: Malformed HTML output
by simX (Novice) on Jul 24, 2003 at 19:30 UTC
    Yeah, I would do that. The only problem is that I can't seem to install one module that is required for my script -- it's Chart::Plot, and every time I try to get CPAN to install it, it fails on installing the GD module, which Chart::Plot is dependent upon, so I can't run my script locally.

    I did notice, though, that commenting out any three hidden text fields fixes the problem -- like the perl script doesn't like to have more than a certain number of hidden text fields. I can't imagine that there's that restriction on HTML files, so any ideas why it would refuse to print out more than a specific number of hidden text fields? It doesn't seem to matter whether I use the hidden() function or print them out manually via text.

    As for checking the HTTP headers and stuff -- I don't think that would be necessary since the script works fine when first run; it just fails when the user inputs a value into the chemical element field. And since commenting out those few lines will get the HTML page to show correctly, it doesn't seem like the HTTP headers would be the problem.
      How did the install of GD fail? Did the compile fail, or did something like just one of the tests fail? If it was just some lame little test that failed then you probably got a message like "will not install without force", in which case you can go into your .cpan directory (or whatever dir you specified for building modules) and do "make install" so as to forcibly install it. Of course, if it broke at some earlier stage it may have been because you're missing some other program/library for which it is a wrapper, in which case forcing an install is decidedly not the right thing to do.
        No, it made a bunch of errors when trying to install GD. I successfully installed GD with fink, but I still can't get the CPAN installer to recognize it, so the Chart::Plot installation fails because it requires GD. Arg. Maybe you know how to fix that, too? That would be awesome.
      I did notice, though, that commenting out any three hidden text fields fixes the problem -- like the perl script doesn't like to have more than a certain number of hidden text fields.
      Could it be that there is a restriction on the size or number of parameters that are being POSTed, either at the server or at your end (proxy)?
        I didn't think so, since I had had the same number of parameters before I started doing all these modifications to the code that landed me into this mess that was finally resolved (see sauoq's reply and the subsequent replies). I had actually removed a few fields that were made unnecessary after some modifications that I had made.

        Thanks for the reply, though. -- simX