• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Retreiving data with register_globals=off

My code was working fine until I upgraded to a newer PHP version, now I'm having major problems.

I have an index page, which takes a var like this: "http://www.mysite.com/index.php?page=12"

I used to use this simple code:

$HTTP_GET_VARS[$page];

to extract the page number, but this no longer works, so can someone please tell me what I should be using.

I know I can turn on register_globals but i dont want to...

Thanks
0
rjdown
Asked:
rjdown
  • 2
  • 2
1 Solution
 
LornaJaneCommented:
You don't need to turn on register_globals, but you do need to refer to your variable differently.  Try using this instead

$GET['page']

I hope this helps :)
0
 
rjdownAuthor Commented:
Thanks for quick reply but still nothing...

I made a new file, test.php:

<?php
$GET['page'];
echo $page;
?>

now if i go to this using test.php?page=23 i still get a blank page? :'(
0
 
LornaJaneCommented:
try this, I don't think I explained myself terribly well before:

<?php
$page = $GET['page'];
echo $page;
?>

If you don't understand what the above code does, post back and I'll explain more clearly
0
 
rjdownAuthor Commented:
Oops, my bad.

I had a look through the php manual and found that it should in fact be $_GET. Horrah, my code works again :D

Thanks Lorna :D

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now