Forum Moderators: coopster

Message Too Old, No Replies

Enabling Query Strings on Dev PC

Getting query strings working

         

Sypher_5

10:45 pm on Jun 13, 2004 (gmt 0)

10+ Year Member



Not having a net connection at home anymore I've had to use my own PC for development transferring files by disk to a PC with a connection.

I've installed Apache and PHP on my pc and it's parsing the PHP however it's not reading the Query Strings in the URL. How do I go about getting it to recognise them?

EG: 127.0.0.6/index.php?dir=_incl&=page1

Should open the index and include a file in _incl called page1. However it's just defaulting to a default page if no Query String is called. Leading me to believe it's not parsing the Query String. This works online on my host.

Are Query Strings not enabled by default or is this because I'm using my PC as a Server & viewing files on it?

Win2k - Apache 1.3.? ( Most recent before Apache 2 ) - & most recent version of PHP.

GeorgeGG

12:52 am on Jun 14, 2004 (gmt 0)

10+ Year Member



'dir=_incl&=page1'
maybe
'dir=_incl&page_name=page1'

GeorgeGG

Sypher_5

2:33 am on Jun 14, 2004 (gmt 0)

10+ Year Member



I meant?dir=_incl&p=page1, small typo.

johnerazo

3:06 am on Jun 14, 2004 (gmt 0)

10+ Year Member



This has something to do with the register_globals setting of PHP. Prior to PHP 4.2.0 its default is set to ON.

With the register_globals ON you can directly refer to variables $_incl and $page_name from the URL [127.0.0.6...]

With the register_globals OFF you use the PHP Superglobal $_POST, $_GET, $_REQUEST, etc. Example, to get the variables from the URL [127.0.0.6...] you refer to them as ...

$dir = $_REQUEST['dir];
$page_name = $_REQUEST['page_name'];

Sypher_5

9:05 pm on Jun 20, 2004 (gmt 0)

10+ Year Member



Thanks.

Sypher_5

8:56 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



I think my next problem is related to this so I'll just add it here.

I'm using is_file to do error checking on the query string varibles to check if those values/includes exist. However it's not working.

if (is_file("$incl")) { 
include($incl);
}
else {
include('$error');
}

I'm guessing something else isn't enabled by default that uses this. It's just going as far as this and including my default $incl which is $home and not using the $error when the called $incl isn't found. This script works on my hosts server just not mine on my PC.

johnerazo

2:41 am on Jun 22, 2004 (gmt 0)

10+ Year Member



Please do...

var_dump($incl);

and post result here.

ergophobe

4:17 pm on Jun 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



how are you redefining $incl in your script?

Are you doing this

$incl = $dir;

or this

$incl = $_GET['dir'];

Try the latter and see if it works.

tom