Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script displays text I don't want.

Status
Not open for further replies.

makuk

Technical User
Apr 16, 2003
10
GB
Hi

I have a shopping cart script that displays some text after the user has added an item to their cart, it appears like this:

1x 5922 - video at £14.95 each has been added to your cart.

We will now return to you to the previous page.

Content-type: text/html

The above line "Content-type: text/html " also appears. I have located where in the script it is but whatever I do I am unable to remove it, here is the section where it appears in the script:

# Print the HTML header
sub print_header {
print "Content-type: text/html\n\n";
open (HEADER,"$basepath/$header") || print "Could not open $basepath/$header $! \n";
while (<HEADER>) {
print $_;
}
close(HEADER);
}

Any help to sort this out would be greatly appreciated.

Thanks

Mark.
 
Are you *certain* that that is the only place that

print &quot;Content-type: text/html\n\n&quot;;

occurs in the script?

Also, what does $basepath/$header have in it? It might
also contain the same print of the Content-type.

HTH. Hardy Merrill
 
Hi

Yes there are other areas that contain this text but I know for a fact (not being big headed) that this is the area that is causing the problem, I have uploaded the script for you to see here:


Thanks for your help.

Regards

Mark.
 
What are the values of $basepath and $header? What file is being read in

open (HEADER,&quot;$basepath/$header&quot;)

??? List the contents of that file here.

Your problem normally only occurs when you print the Content-type line twice - once it gets used properly in the header, and the 2nd time it gets printed out on your web page. Hardy Merrill
 
Hi

Thanks for replying.

Unfortunately, this is my first learning excercise using PERL, I really have no idea what you mean by the above.

I just edited the script until I got what I wanted and ended up with the error shown above.

Thanks

Mark.
 
Anyone else got any ideas, as I really need to sort this.

Thanks

Makuk
 
Mark -- this construct here $basepath/$header, used in your open statement, holds the name of a file.

The actual name of the file is made up of the contents of the variable $basepath, a /, and the contents of the variable $header.

In your print_header function, put the following two lines at the beginning of the function.

print &quot;filename = $basepath/$header\n&quot;;
exit;

That will display a filename, have a look in that file and tell us what's in there. Mike
______________________________________________________________________
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
$basepath/$header

are not declare in your script ???

they should be something like
Code:
$basepath = &quot;usr//bin//path//to//my//base//directory&quot;;
$hearder = &quot;afile.file&quot;;

as well as $footer is not declared as many others...
check all your &quot;
Code:
open()
&quot; statements ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
I just fixed this same problem in a script. It had the Content-type statement near the top of the page, and it also had it in an error sub. When this error sub was called it printed Content-type: text/html. Try removing the content-type statement from your sub and see what happens.
Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top