in reply to CGI && tables nested within tables.

Your old nested() function returned some HTML, but your new nested() function is printing its HTML before the main code has printed the header or anything else. The text printed by nested() is breaking your HTTP headers, which produces the result you're reporting.

Solution: nested() should return the HTML instead of printing it.

Note that running your CGI script from the command line probably would have revealed the problem.

  • Comment on Re: CGI && tables nested within tables.

Replies are listed 'Best First'.
Re: Re: CGI && tables nested within tables.
by Macphisto (Hermit) on Dec 29, 2000 at 01:14 UTC
    Thanks Chipmunk,
    I was struggling with that and just didn't look at it as one giant print statement thus didn't realize it wouldn't have finished until the ';' I'm very impressed that you caught that so quickly. You answered in mere minutes.
    p.s. You mentioned running the cgi at the command line. Are you referring to 'perl -wcT foo.cgi' or something else?

    Everyone has their demons....
      Yes, you can run your script from the command line to see what output it produces, including the HTTP headers which the browser doesn't show you. Something like: `perl -wT foo.cgi`. Use -c to make sure the script compiles, then leave it off to see what output you get.

      Because CGI scripts get their input from the environment and standard input, you can run your script from the command line with all the data it would get from the web server. For example, you can set QUERY_STRING in your shell's environment to 'id=7&name=bob'.

      The CGI module provides a debug mode when run under the shell to make this easier. Run the script from the shell, and you can include parameters and values on the command line or pass them through standard input. (See the DEBUGGING section of the manpage for more details.)