KapTinKiRk November 5th, 2000, 20:53 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...
$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.
$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 ;)
cds November 5th, 2000, 20:56 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]
KapTinKiRk November 5th, 2000, 21:12 the page comes up, but it shows up blank
Grant November 5th, 2000, 21:50 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...
$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.
$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:
$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:
$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:
$sectionID = "$INPUT{'sectionID'}";
if($sectionID == 1){
$section = "home/";
}
elsif ($sectionID == 2){
$section = "movies/";
}
elsif ($sectionID == 3){
$section = "movies/previews/";
}
cds November 5th, 2000, 21:53 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 :)
KapTinKiRk November 5th, 2000, 22:11 yea, got it working, thanks cds... surprising to see you here Grant ;)
cds November 5th, 2000, 22:26 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! :)
Grant November 5th, 2000, 23:18 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.
KapTinKiRk November 6th, 2000, 14:00 I also changed the code to the standard numerical comaparison, because Stone Cold Grant said so :P
|
|