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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why the html part does not print in this perl script?

Status
Not open for further replies.

JASONE25

Technical User
Jun 23, 2005
54
NL
Hi guys i try to run this script but i get this error :


Code:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


Undefined subroutine &main::HTMLGetRequest called at c:\inetpub\[URL unfurl="true"]wwwroot\cgi-bin\jukebox2006\textchat\pop.pl[/URL] line 22.
This is the way i call it:
http://localhost/cgi-bin/jukebox2006/textchat/pop.pl?name=ID11

Could any one help me fix this error. I am run perl locally and using iis5 .Thanks


Code:
#!/usr/bin/perl

&HTMLGetRequest;
#these are the variable  recived from the edit box.We declare them here
$fname=$rqpairs{"name"}; 


# Set Your Options:
$redirection = 0;       # 1 = Yes; 0 = No

#Note: 
# SONG LOCATIONS


#Defult Subroutines

&HTMLContentType; 


print <<method;

<html>

<head>

<title> Music</title>
</head>

<frameset framespacing="0" border="0" rows="85,70,*" frameborder="0">
  <frame name="top" scrolling="no" noresize target="middle" src="[URL unfurl="true"]http://localhost/jukeboxwall.html">[/URL]
  <frameset cols="92,300,40%">
  <frame name="middle" target="bottom" src="[URL unfurl="true"]http://localhost/jukeboxwall.html"[/URL] scrolling="no" noresize>
    <frame name="middle1" src="[URL unfurl="true"]http://localhost/textchat/popjukebox.pl?name=$fname"[/URL] scrolling="no" noresize>
    <frame name="middle2" src="[URL unfurl="true"]http://localhost/jukeboxwall.html"[/URL] scrolling="no" noresize>
  </frameset>
  <frame name="bottom" src="[URL unfurl="true"]http://localhost/jukeboxwall.html"[/URL] scrolling="no" noresize>
  <noframes>

<body bgColor=#336699>
    
</body>
</html>




method
 
It's telling you that there's no such subroutine as HTMLGetRequest, which you're trying to call in your second line.

Also, you're not printing a valid header.
 
thanks for u reply . If i remove the line how i could print the html part? Could u tell me what u mean by header part as i am new to perl.Thanks
 
I'd seriously recommend this tutorial for *anybody* who's new to Perl and CGI. Ovid teaches it far better than I could.
 
Please do listen to ishnid

But, if you want to get the HTML part, then do the following:

1. remove, or comment out, BOTH the &HTMLGetRequest; and &HTMLContentType;

2. end the script like this
method
# end of script


(just to get the HTML output)

I won't go into why - but if you do this the HTML will appear


Kind Regards
Duncan
 
Many thanks duncdude i made the changes and it printed out the html part. But unfortunely when i call the script like this :


it does not pass the value 2 and the value 2 does not appear in this instaed of $fname :

<frame name="middle1" src=" scrolling="no" noresize>

i be happy if u help me fix this problem.Thanks
 
$fname doesn't have anything in it because in your first line, the %rqpairs hash is empty.

I showed you in your other thread how to get the value of a parameter passed in the query string (by using CGI's param() method).

Please, please, please take the time to read the tutorial I linked to above. If nothing else, it will save you a lot of time, since you won't have to wait for us to post replies to your questions. It will also teach you the best way of going about CGI programming with Perl.
 
Please, please, please take the time to read the tutorial I linked to above. If nothing else, it will save you a lot of time, since you won't have to wait for us to post replies to your questions. It will also teach you the best way of going about CGI programming with Perl.

Yes, I posted that twice on purpose. It's *that* important. If there are parts of the tutorial you don't understand, feel free to ask us.
 
JASONE25

MAKE NO MISTAKE - THIS IS WRONG OF ME TO DO THIS AS YOU ARE NOT INVESTING ANY TIME OR EFFORT INTO LEARNING HOW TO GO ABOUT THIS PROPERLY

This is an awful quick-fix (and ishnid will probably hate me for it - and i wouldn't blame him)

If you put this at the top of your script it should work

Code:
[b]#!/usr/bin/perl[/b]

@pairs = split(/&/, $ENV{"QUERY_STRING"});

foreach $pair (@pairs) {
 ($name, $value) = split (/=/, $pair);
 $formData{"$name"} = $value;
}

$fname = $formData{name};

In my previous post I was trying to explain simply how to make a print HERE document work - you need a hard-return at the end of the print HERE statement

I was NOT trying to explain how to make the script work - or how to parse data


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top