Solved

Retreiving data with register_globals=off

Posted on 2003-12-03
4
225 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
  • 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 50 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

856 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