?
Solved

Retreiving data with register_globals=off

Posted on 2003-12-03
4
Medium Priority
?
236 Views
Last Modified: 2006-11-17
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
Comment
Question by:rjdown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:LornaJane
ID: 9867008
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
 
LVL 6

Author Comment

by:rjdown
ID: 9867112
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
 
LVL 5

Accepted Solution

by:
LornaJane earned 200 total points
ID: 9867210
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
 
LVL 6

Author Comment

by:rjdown
ID: 9867586
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question