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

cgi URL param driving me mad. Please help!

Status
Not open for further replies.
Mar 11, 2004
127
GB
Hi,

For some reason I can't get a param that I'm passing in the URL to work, and its driving me nuts.

I have a "cgi-bin/test.cgi?selection=R33" URL that I am trying to get to work.

When I manually define $selection = "R33"; it works fine. When I try to pass R33 as a parameter on the URL (as above)it gives me an error which I can't figure out.

#my $selection="R33";
my $query = CGI->new();
my $selection = $query->param('selection');

I know its going to be something simple that I haven't figured out yet as this is my first attempt.

Any advice would be super though.

Thanks in advance,
Anthony
 
Not sure what the error was. Couldn't get anything from the log.

I've got to the bottom of it though after trawling google and sites all day. It seemed I was missing the: use CGI 'param'; - it all now seems to be working. Will play around a bit more now.

SO for search purposes the solution was

use CGI 'param';
$selection = param('selection');
$datafile="gtr_data.csv";

href="/cgi-bin/test.cgi?selection=R33"

Cheers,
Ant
 
That's weird. Object-oriented CGI should work fine. I use something along the following lines in most of my CGI scripts...

Code:
#!/usr/bin/perl -w

use CGI;
use URI::Escape;

my $cgi = new CGI;
my $query = {};

foreach my $what ($cgi->param) {
   my $is = $cgi->param($what);
   $is = uri_unescape ($is);
   $query->{$what} = $is;
}

print "Content-Type: text/html\n\n";
print $query->{selection}; # or whatever

-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top