Connecting Tech Pros Worldwide Forums | Help | Site Map

"Content-type" etc displaying in browser

Newbie
 
Join Date: Mar 2007
Location: Sydney, Australia
Posts: 18
#1: Sep 1 '07
Hello everyone,

I'm learning Perl again!

I am writing a CGI script that has two possible outcomes. So I have broken up the HTML output into four parts:

Beginning (header and the start of the HTML)

Option 1 OR
Option 2

Ending (remainder of the HTML)

This works fine as a program, the different options display according to the input. However, at the top of the second and third parts to display (ie. Option 1 and then the Ending or Option 2 and then the Ending), there is an annoying piece of text that shouldn't be there:

Quote:
Content-Type: text/html; charset=ISO-8859-1
The code for the various HTML outputs is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. if ($id == $transaction) {
  3.  
  4.     # we can print the results
  5.  
  6.     print header, <<"EOF";
  7.  
  8. [various HTML stuff]
  9.  
  10. EOF
  11.  
  12.  
For the Beginning, this works without any unseemly messages. For the Options and End the message appears. I have tried adding:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
To the non-Beginning outputs, but this has not surpressed the message.

Does anyone have an idea as to what to try next?

Thanks!
David
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,569
#2: Sep 1 '07

re: "Content-type" etc displaying in browser


Hello! Welcome back to Perl again.

Would it be possible for you to post your whole code so we could evaluate it and see if we can find where the extra text might be coming from?

Regards,

Jeff
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#3: Sep 1 '07

re: "Content-type" etc displaying in browser


look in the script, you might have this twice and it's gtting printed twice:

print header

the header needs to only be printed once.
Newbie
 
Join Date: Mar 2007
Location: Sydney, Australia
Posts: 18
#4: Sep 1 '07

re: "Content-type" etc displaying in browser


Thank you SO much KevinADC, that was exactly the problem!
Reply