Forum Moderators: coopster

Message Too Old, No Replies

nested $_GET

or so i think....

         

kumarsena

1:00 pm on Sep 25, 2004 (gmt 0)

10+ Year Member



i got this link:

index.php3?art=culinaries/printfile.php3?receipe=$file

index.php2 works as a template in which information is loaded by $art. in the above example im inlcuding a script called printfile.php3. this one needs a var to function, called receipe. but this is giving me error...is it possible to do this at all,

folder structure as this:

index.php3 in root calling
printfile.php3 in folder 'culinaries' which contains
folder receipes with textfiles referencd by $file

any suggestions?

kumar

mincklerstraat

2:17 pm on Sep 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try index.php3?art=culinaries/printfile.php3&receipe=$file

your HTML should output:
index.php3?art=culinaries/printfile.php3&receipe=$file

this is in the case you just have one script that needs to load up something (parameter 'art') and needs another parameter re. the info it needs to load up ('recipie' & nb you might want to check the spelling of recipie, yeah, I know, I'm a born nit-picker). I think we've gone over the dangers of doing dynamic file includes with user-input variables, which you always have with $_GET and $_POST - if not, think about a good naming convention for your files that are dynamically included, or some strategy to assure that scriptkiddies aren't able to include any files except those that you intend being dynamically includable.

in the case that culinaries/printfile.php3?receipe=$file is a page producing output, and you somehow want to do something with the HTML output of this page (which seems less likely the case), have a look at the functions urlencode and urldecode.

kumarsena

2:19 pm on Sep 25, 2004 (gmt 0)

10+ Year Member



ok guys,

got it sorted....

just a small change needed...

"index.php3?art=culinaries/printfile.php3&receipe=$file

just had to think trough how php processes include functions...and it made sense...if anyone wonders...

initial code
"index.php3?art=culinaries/printfile.php3?receipe=$file
new code
"index.php3?art=culinaries/printfile.php3&receipe=$file

i guess the difference is because after inclkuding printfile it sort of becomes part of the output index.php3 files, so that the value that ewe pass to printfile should be passed to index.php3. only a guess but it worked so i guess its right..

any comments from those with more knowledge is appreciated.

thanks
kumar

mincklerstraat

5:28 pm on Sep 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Think of it like this, k.:

Whatever file that's called is important for some reasons - it determines the 'base' url from which php looks for include files, it 'starts' the php and is the beginning of the 'global namespace' - i.e., where ordinary variables are valid. Any stuff that's included, even if it houses the main part of the script that's run for that particular thing it does, is 'just' an include. Doesn't effect the rest of this bit. This goes for any variables that come in with post and get. They're valid the whole way through your script.

Parameters are always valid from the beginning to the end of the script, and are never valid only for 'part' of the script that may be included - that said, however, it may only be 'part' of the script that actually uses some of your variables.

kumarsena

6:25 pm on Sep 25, 2004 (gmt 0)

10+ Year Member



hey micklerstraat,

didnt see your first input there, must have posted as i was writing second..

anyway, your second input explained a few things, thank you.

and yup, my spelling has gotten worse latley...im sure u can pick out more in my posts...:)

once again, uve been pretty helpful today, very much appreciated...

k