Find the answer to your Linux question:
Results 1 to 5 of 5
I just installed PHP 5.0.18 on a SuSE Linux server. Everything else seems to work allright, but the variables which are sent with URL are ignored. On a page with ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14

    URL variables do not come across with PHP

    I just installed PHP 5.0.18 on a SuSE Linux server. Everything else seems to work allright, but the variables which are sent with URL are ignored.

    On a page with URL
    mypage.php?variable=3


    This code should print ´3´ , but it does not.
    echo "$variable";


    Did I overlook something when I installed PHP?

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    PHP does not automatically create the variables for you to use. Instead, they are passed in a special array depending on how they were passed: $_POST for POST variables, and $_GET for GET variables. If you don't care, then you can use $_REQUEST.

    So we can one of the following:
    Code:
    echo $_GET['variable'];
    echo $_REQUEST['variable'];
    Hope that helps.
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14
    $_GET[] and $_REQUEST[] do work, but why does this code give different resul on my recently installed server than on my old server

    Code:
    <?php
    echo "<a href=mypage.php?var=2>click</a>";
    echo "<br>first ";
    echo $var;
    echo "<br>second ";
    echo $_REQUEST['var'];
    ?>

    On my new server clicking on the link produces page like this
    click
    first
    second 2
    whereas the old server gives a page like this
    click
    first 2
    second 2
    Otherwise I would not mind, but there will be one helluva lot of work in adding "$_REQUEST" to my formerly written codes.

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    This is a change made in PHP 4.2.0. It is well explained at:
    PHP: Using Register Globals - Manual
    DISTRO=Arch
    Registered Linux User #388732

  5. #5
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14
    I get it. Thanks

Posting Permissions

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