SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET not available problem

    I have the following code:

    <?php

    print "1. " . $_GET['c'] . "-2. " . $_GET['s'];

    ?>

    The file is called test_globals.php.
    On most servers I can type:

    http://servername/test_globals.php?c=yes&s=no

    and the output will be similar to:

    1. yes-2. no

    However, on one server, I get the following result:

    1. -2.

    My question is, why doesn't $_GET return the values of "yes" and "no" ?
    On this server (which is running Apache 2.0 and PHP 4.2.2), register_globals is set to 'on' and safe-mode is set to 'off'. I've already tried to change the code to:

    <?php

    print "1. " . $c . "-2. " . $s;

    ?>

    and still get the result:

    1. -2.

    Are there any other directives that must be set in a certain way to enable
    $_GET ? Also, this server is secure, so that I use the protocol of "https" rather than "http" for this page. I'm not sure if that matters.

    I have also tried substituting $_GET with $HTTP_GET_VARS and receive the same result.

    Thanks all.
    Sean

  2. #2
    SitePoint Guru Marc's Avatar
    Join Date
    Nov 2000
    Location
    New York
    Posts
    765
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What happens if you try this code in test_globals.php:
    PHP Code:
    print_r($_REQUEST); 
    Marc Gugliuzza
    marc.gugliuzza.com



  3. #3
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the method above didn't work, try created a form to post vars to your script, then print $_REQUEST again. PHP could be blocking GET requests.

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2002
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to replace your php.ini file with original one.

  5. #5
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, per your suggestions, I did try the code:

    <?php
    print_r($_REQUEST);
    ?>

    and the output I receive is:

    Array ()

    I also tried to create a form and post the variables c and s,
    but the above code still gives me:

    Array ()

    Could PHP be set up to block $_GET and $POST requests?
    Replace the php.ini file with original? The problem is I don't have access
    to php.ini, nor do I know if it is the original or not. Could this really affect
    $_GET and $_POST?

    Thanks again,
    Sean

  6. #6
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's really weird. Contact your host and tell them you cannot receive GET and POST variables through php.

  7. #7
    SitePoint Zealot
    Join Date
    Oct 2005
    Location
    Hegelsom, The Netherlands
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to check, what PHP version is the server running?

    Prior to version 4.1.0 you should use $HTTP_GET_VARS instead of $_GET

    I'd be quite surprised if you're running a version lower than 4.1.0 but in theory, it's possible.

  8. #8
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tim,

    the system is running PHP version 4.2.2
    The webserver is Apache 2.0.

    Thanks,
    Sean

  9. #9
    SitePoint Zealot
    Join Date
    Oct 2005
    Location
    Hegelsom, The Netherlands
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried using $HTTP_GET_VARS yet though?

    In the meantime I'll try to do some research :P

  10. #10
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tim,

    yes, I've tried using $HTTP_GET_VARS
    when I attempt:

    <%php
    print_r($HTTP_GET_VARS);
    %>

    I get:

    Array()

    as the output.
    One thing, though, that I learned was that when I try:

    <%php
    phpinfo();
    %>

    The output doesn't contain an "Apache Environment"
    section with variables and values. I've run this on another
    server whose output did have the "Apache Environment"
    section. I'm not sure if this means anything, though, just
    something I noticed that was different.

    Thanks,
    Sean

  11. #11
    SitePoint Zealot
    Join Date
    Oct 2005
    Location
    Hegelsom, The Netherlands
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, that's weird. I'll see if I can come up with something. Weird problem indeed :P


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •