-2

Just upgrade php, very simple sample does not work properly

test.php

 <?php 

 echo "$query";

 ?> 

when I call

test.php?query=5

It should display

5

but What I got is nothing display which mean $query is ''

Your comment welcome

arachide
  • 8,006
  • 18
  • 71
  • 134

5 Answers5

2

Try using

$query = $_GET['query'];
mittmemo
  • 2,062
  • 3
  • 20
  • 27
2

Its a new secuirty feature. It used to be called register globals.

http://php.net/manual/en/security.globals.php

Not you have to use the $_GET, $_POST or use $_REQUEST global variables to obtain this information.

for example your code would be

 <?php 

 echo $_GET['query'];

 ?> 
exussum
  • 18,275
  • 8
  • 32
  • 65
1

In your previous PHP register_globals directive was on, allowing you to use $REQUEST array's elements as global variables. That's why the code worked. This feature was deprecated in PHP 5.3.0 and removed in PHP 5.4.0: http://www.php.net/manual/en/ini.core.php#ini.register-globals

Don't use it. Apply to $_GET, $_POST and $_REQUEST arrays directly.

What are register_globals in PHP?

Community
  • 1
  • 1
user4035
  • 22,508
  • 11
  • 59
  • 94
1

Your upgrade turned off the insecure, horrible, and smelly register_globals. You are better off for this, despite the work you must now do.

You will have to change every instance of

$query

to

$_GET['query']

File the time spent under "Security".

willoller
  • 7,106
  • 1
  • 35
  • 63
0

You need to use $_GET

An associative array of variables passed to the current script via the URL parameters.

http://www.php.net/manual/en/reserved.variables.get.php

$query = $_GET['query'];
doitlikejustin
  • 6,293
  • 2
  • 40
  • 68