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!

Newbie needs help with QueryString

Status
Not open for further replies.

jimny

Technical User
Oct 18, 2002
52
US
I inherited a PERl/PHP(and I am not familiar with) site and am getting an error when looking for a querystring value.

the original HREF is like:
Code:
<A class=listLink 
href=&quot;artist_frame.shtml?artist_id=10&quot; 
target=cag_content>Artist 10</A>
and the code on the recieving page is:
Code:
$id = $HTTP_GET_VARS['artist_id'];

I don't know where &quot;$HTTP_GET_VARS[]&quot; lives so I am trying to capture the artist_id value from the querystring using:
Code:
($key, $id) = split(/=/,$ENV{'QUERY_STRING'},2);
#since there is only one variable

and I get:

Parse error: parse error, unexpected ',' in artist_frame.php on line 4

if I go with:
Code:
@vals = split(/=/,$ENV{'QUERY_STRING'});
I get:
Parse error: parse error, unexpected '=' in artist_frame.php on line 4

What am I doing wrong? I tried declaring the variables and that didn't help either...Is their something server side that I need to set or include?


 
Are you asking a Perl or a PHP question? If you're asking a Perl question, the easiest way to get it would be using the CGI module and giving the file the proper bang line (#!/path/to/perl -w) and extension..
Code:
use CGI;
my $cgi = new CGI;
my $query_value = $cgi->param('artist_id');
Voila... you're done. And as long as you keep your CGI module up to date, you'll rarely (if ever) need to alter the code relating to fetching that parameter even if the entire specification for doing such a thing changes.

If you're asking a PHP question you posted in the wrong place..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top