2

I can't for the life of me figure out why my attempts at using $_GET are not working. As near as I can tell, I'm using it correctly, as I've used it in the past.

The link seems to be formatted correctly

<a href="script.php?variable=value">Value</a> 

since I receive the correct information in the URL:

localhost.com/script.php?variable=value 

but neither simply using:

$var = $_GET['variable']; 

or using either of these two:

if (!isset($_GET['variable'])) { $var = $_GET['variable']; } if (isset($_GET['variable'])) { $var = $_GET['variable']; } 

nothing I do seems to be working, does anyone have any suggestions as to what to look out for?

14
  • Error or just empty string? Commented Apr 29, 2013 at 21:03
  • 3
    post results for var_dump($_GET); Commented Apr 29, 2013 at 21:04
  • Do you get the same result if using $_REQUEST['variable']? Commented Apr 29, 2013 at 21:04
  • 3
    It's possible that the request is being rewritten by something like .htaccess (without the [QSA] flag). You can also check out the value of the php.net/manual/en/ini.core.php#ini.variables-order setting, which can disable certain superglobals. Commented Apr 29, 2013 at 21:06
  • 1
    Sounds to me like .htaccess could be rewriting it. Or, by any chance, are you using php shorthand tags (<? instead of <?php) with the short_open_tag disabled? Commented Apr 29, 2013 at 21:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.