tags:

views:

113

answers:

1

I am a beginner in php and am trying some very simple tests to get started.

I seem to be unable to get any values from $_GET.

This test.php

#!/usr/bin/php

<html>
<body><h1>GET test</h1><p>
<?php
    print_r($_GET);
?>
</p></body></html>

produces the following when called with http://my.url/test.php?aValue=A&amp;bValue=B

<html>
<body><h1>GET test</h1><p>
Array
(
)
</p></body></html>

I do not have write access to /etc/php.ini on the server, but check register_globals and it is off.

I have also tried using $_POST method, but this also doesn't work.

PHP version: PHP 5.1.6

+3  A: 

The $_GET and $_POST variables are only available if track_vars is turned on.

As of PHP version 4.0.3 that is always automatically enabled.

Can you check your PHP version and also check the value of track_vars in php.ini?

It would also be helpful if you check phpinfo();

<?php
phpinfo();
?>

Check for

  • something called --enable-track-vars, which should be present.

  • _SERVER["argv"], should contain an array if you pass vars via a GET request.

  • also "Loaded Configuration File" should resolve to the file you think it is.

source: PHP: Description of core php.ini directives

nash
Thanks nash. The PHP version is PHP 5.1.6. I checked php.ini and there was no setting of track_vars. There were some comments about how it is on by default though. I tried phpinfo() and it looks like it's right ( --enable-track-vars was in there).
Myf