Page 1 of 1

php won't parse variables from the URL into the php page

Posted: Sat Jan 24, 2004 9:07 am
by ASuriel
Hi there. I am currently trying to get a file called linker.php to inlcude the pages that i tell it to. Now the page linker.php is called into a frame named main.

so, I have these links which link to

Code: Select all

href="htm/linker.php?category=about.htm" target="main"
but i constantly get an error message that says "Undefined variable: category ..."

so it seems that the page linker.php never gets the variables!

the code in the linker.php file is as follows:

Code: Select all

<?php
include($category);
?>
whats wrong with my script?

Posted: Sat Jan 24, 2004 9:07 am
by markl999
If you have register_globals Off (which it is by default with PHP => 4.2.0) then you'll need to use $_GET['category']

Posted: Sat Jan 24, 2004 9:25 am
by ASuriel
how do i turn it on? and now i get following error
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
and the code

Code: Select all

<?php
include("$_GET&#1111;'category']/$_GET&#1111;'page']");
?>

Posted: Sat Jan 24, 2004 9:38 am
by markl999

Code: Select all

include $_GET&#1111;'category'].'/'.$_GET&#1111;'page'];
Don't forget all your validation, checking the file exists, the vars are set/passed in the url, and that not just any old file can be included (/etc/passwd) etc..etc.. :)