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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ASuriel
Forum Newbie
Posts: 2
Joined: Sat Jan 24, 2004 9:07 am

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

Post 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?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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']
ASuriel
Forum Newbie
Posts: 2
Joined: Sat Jan 24, 2004 9:07 am

Post 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']");
?>
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.. :)
Post Reply