Search code examples
phpphp-5.6php-5.4

Php 5.4 upgrade to 5.6 : GET variables issues


I created a little website from scratch with Mysql database, PHP Sessions etc... on my local WAMP with PHP 5.4.

When uploading the website files to my online host - which is running PHP 5.6 - I have issues with all the GET variables, it seems to not be functionnal.

On my local computer :

// Requested URL : index.php?title=Hello
<?php

echo $_GET["title"]; // works

?>

On the server :

// Requested URL : index.php?title=Hello
<?php

echo $_GET["title"]; // empty. 

?>

Crazy ! I do not understand what happens... I read the "Migrating from PHP 5.4.x to PHP 5.6.x" and the "Migrating from PHP 5.5.x to PHP 5.6.x" but I don't manage to find what is not working.

Do you have any idea ?

EDIT 01/13 : I created a very simple form page :

<?php
echo $_POST["texttest"]."<hr />";
?>

<form action="?" method="POST">
<input type="text" name="texttest" class="texttest" id="texttest" />
<input type="submit" value="test">
</form>

.. The POST var is never displayed. When I look in the Chrome console after submitting the form, I have a message :

Provisional headers are shown


Solution

  • setup a test script with phpinfo to see what your ini variables are on the host.

    <?php
    phpinfo();
    ?>
    

    http://php.net/manual/en/ini.core.php#ini.variables-order if variables-order is set a certain way - $_GET might not be available...

    Mine is set to:

    ; This directive determines which super global arrays are registered when PHP
    ; starts up. G,P,C,E & S are abbreviations for the following respective super
    ; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty
    ; paid for the registration of these arrays and because ENV is not as commonly
    ; used as the others, ENV is not recommended on productions servers. You
    ; can still get access to the environment variables through getenv() should you
    ; need to.
    ; Default Value: "EGPCS"
    ; Development Value: "GPCS"
    ; Production Value: "GPCS";
    ; http://php.net/variables-order
    variables_order = "GPCS"
    

    If you have access to your php.ini - you can simply change it.

    EDIT: OK - confirmed that variables_order = "GPCS".
    if the source test code is edited to this - what is the result?

    <?php 
    echo 'This is my page'; // should always print- just to make sure you are on the correct page 
    echo '$_REQUEST:'.print_r($_REQUEST,true); 
    echo '$_GET: '.print_r($_GET,true); 
    echo '$_POST: '.print_r($_POST,true); 
    echo $_GET["title"]; // empty. 
    ?>