Closed Thread
Results 1 to 9 of 9

Thread: query string question

  1. #1
    Pro Member KapTinKiRk is an unknown quantity at this point KapTinKiRk's Avatar
    Join Date
    Oct 2000
    Location
    CT
    Posts
    252
    I'm trying to edit a script so that I can use the query string to decide which directory the script will read. But the thing is I want to do it with numbers.

    script.cgi?sectionID=2&id=pagename

    So then '2' will equal to a path name...

    /path/to/whatever/

    and the id query is the name of the file. I've gotten it to work when I only use the id string, which is pretty simple. But my big problem is, how do I go about telling the script where to go for each number?

    1 = "/path/to/whatever"
    2 = "/path/to/somewhere"

    I did the following...

    Code:
    $sectionID = "$INPUT{'sectionID'}";
    $section = "home/" if ($sectionID eq '1');
    and it works, but when I need to add the ones for 2, 3, 4 etc. etc.

    Code:
    $sectionID = "$INPUT{'sectionID'}";
    $section = "home/" if ($sectionID eq '1');
    $section = "movies/" if ($sectionID eq '2');
    $section = "movies/previews/" if ($sectionID eq '3');
    ..it gives errors, anyone know how to do this properly? Any help is appreciated. If I didn't explain it enough, then tell me

  2. #2
    Pro Member cds is an unknown quantity at this point
    Join Date
    Nov 2000
    Posts
    260
    It would help if you posted what the errors are... does it work but doesn't give the desired results, or does it come up with a error code?

    At first glance, it looks ok, but then again im working on assembly for class so my mind is astray

    [Edited by cds on 11-05-2000 at 09:59 PM]

  3. #3
    Pro Member KapTinKiRk is an unknown quantity at this point KapTinKiRk's Avatar
    Join Date
    Oct 2000
    Location
    CT
    Posts
    252
    the page comes up, but it shows up blank

  4. #4
    Junior Member Grant is an unknown quantity at this point
    Join Date
    Nov 2000
    Posts
    19
    Originally posted by KapTinKiRk
    I'm trying to edit a script so that I can use the query string to decide which directory the script will read. But the thing is I want to do it with numbers.

    script.cgi?sectionID=2&id=pagename

    So then '2' will equal to a path name...

    /path/to/whatever/

    and the id query is the name of the file. I've gotten it to work when I only use the id string, which is pretty simple. But my big problem is, how do I go about telling the script where to go for each number?

    1 = "/path/to/whatever"
    2 = "/path/to/somewhere"

    I did the following...

    Code:
    $sectionID = "$INPUT{'sectionID'}";
    $section = "home/" if ($sectionID eq '1');
    and it works, but when I need to add the ones for 2, 3, 4 etc. etc.

    Code:
    $sectionID = "$INPUT{'sectionID'}";
    $section = "home/" if ($sectionID eq '1');
    $section = "movies/" if ($sectionID eq '2');
    $section = "movies/previews/" if ($sectionID eq '3');
    ..it gives errors, anyone know how to do this properly? Any help is appreciated. If I didn't explain it enough, then tell me
    Instead of using this method for your if else statments:
    Code:
    $sectionID = "$INPUT{'sectionID'}";
    $section = "home/" if ($sectionID eq '1');
    $section = "movies/" if ($sectionID eq '2');
    $section = "movies/previews/" if ($sectionID eq '3');
    You should probably use the standard format:

    Code:
    $sectionID = "$INPUT{'sectionID'}";
    if($sectionID eq '1'){
      $section = "home/";
    }
    elsif ($sectionID eq '2'){
      $section = "movies/";
    }
    elsif ($sectionID eq '3'){
      $section = "movies/previews/";
    }
    You should also probably use the numerical comparison instead of the literal comparison. So the code should be like this:

    Code:
    $sectionID = "$INPUT{'sectionID'}";
    if($sectionID == 1){
      $section = "home/";
    }
    elsif ($sectionID == 2){
      $section = "movies/";
    }
    elsif ($sectionID == 3){
      $section = "movies/previews/";
    }

  5. #5
    Pro Member cds is an unknown quantity at this point
    Join Date
    Nov 2000
    Posts
    260
    Dont worry about it(but thanks)...we've solved his problem

    The prob was that you couldn't expect an include script to execute its code...so just put in a sub, and execute that...simple

  6. #6
    Pro Member KapTinKiRk is an unknown quantity at this point KapTinKiRk's Avatar
    Join Date
    Oct 2000
    Location
    CT
    Posts
    252
    yea, got it working, thanks cds... surprising to see you here Grant

  7. #7
    Pro Member cds is an unknown quantity at this point
    Join Date
    Nov 2000
    Posts
    260
    I really admire your work Grant...especially with your news system...

    I hope that you will continue to post in the future...we will all be better off for it!

  8. #8
    Junior Member Grant is an unknown quantity at this point
    Join Date
    Nov 2000
    Posts
    19
    Originally posted by KapTinKiRk
    yea, got it working, thanks cds... surprising to see you here Grant
    Glad you got it working. Yeah, I try to stop by this board when I get a chance
    Originally posted by cds
    I really admire your work Grant...especially with your news system...

    I hope that you will continue to post in the future...we will all be better off for it!
    Thanks for the compliments. I will continue to try and post on this board whenever I have the time. Thanks.

  9. #9
    Pro Member KapTinKiRk is an unknown quantity at this point KapTinKiRk's Avatar
    Join Date
    Oct 2000
    Location
    CT
    Posts
    252

    Sad

    I also changed the code to the standard numerical comaparison, because Stone Cold Grant said so

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts