Php Variable in HTML Link

I'm trying to pass a variable from a hyperlink to the next page. Click on link one and one value is transfered. Click on link two and a different link is passed. The code I'm using is:
Selection 1
Selection 2


And the variable is being passed to a page with the following code:
$selection = $_GET['selection'];
print $selection;

I cannot get this to work. I'd appreciate any help. This problem is keeping me from progressing on a massive project. THANK YOU!
«1

Comments

  • This should work... Strange... Maybe there's register_globals is off in your ini file. I don't know if this should matter for $_GET, or only for $HTTP_GET_VARS... Do you get an error message...?

    -mac-

    : I'm trying to pass a variable from a hyperlink to the next page. Click on link one and one value is transfered. Click on link two and a different link is passed. The code I'm using is:
    : Selection 1
    : Selection 2
    :
    :
    : And the variable is being passed to a page with the following code:
    : $selection = $_GET['selection'];
    : print $selection;
    :
    : I cannot get this to work. I'd appreciate any help. This problem is keeping me from progressing on a massive project. THANK YOU!
    :

    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...


  • No. No error message. I'm just not getting anything printed to the screen at all. If you would like to view the files they are:

    http://www.jamesa3.com/test4.html
    http://www.jamesa3.com/test5.php

    Since you would not be able to see the code in the php file here it is in its entirety:






    <?php
    $selection = $_GET['selection'];
    print $selection;
    ?>


  • [b][red]This message was edited by tvienti at 2005-7-19 8:10:41[/red][/b][hr]
    Odd. Try putting in this line and see what it does:

    [code]
    print_r($_GET);
    [/code]

    : No. No error message. I'm just not getting anything printed to the screen at all. If you would like to view the files they are:
    :
    : http://www.jamesa3.com/test4.html
    : http://www.jamesa3.com/test5.php
    :
    : Since you would not be able to see the code in the php file here it is in its entirety:
    :
    :
    :
    :
    :
    :
    : <?php
    : $selection = $_GET['selection'];
    : print $selection;
    : ?>
    :
    :
    :



  • No results. I have also verified that my globals are on.
  • I'm baffled. Can you post the results of a php_info()? Also let us know what server you're running..

    : No results. I have also verified that my globals are on.
    :

  • Mozilla even crashed when I opened the PHP file with parameter selection=2

    How bizar (tadada tadada tadada tadada... :-) )
    : No. No error message. I'm just not getting anything printed to the screen at all. If you would like to view the files they are:
    :
    : http://www.jamesa3.com/test4.html
    : http://www.jamesa3.com/test5.php
    :
    : Since you would not be able to see the code in the php file here it is in its entirety:
    :
    :
    :
    :
    :
    :
    : <?php
    : $selection = $_GET['selection'];
    : print $selection;
    : ?>
    :
    :
    :

    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...


  • This link will give you the php info for my server:

    http://www.jamesa3.com/phpinfo.php
  • Ok I'm not positive but I believe it might be because of your variables_order config. This tells PHP what order to process and assign $_GET, $_POST, $_SERVER, $_COOKIE AND $_ENV in. I think the default setting is "EGPCS". According to your php_info() that currently has no value.

    Try going into php.ini and setting the variables_order directive to "EGPCS". Restart your web server and give it another shot, maybe this will fix your problem.

    If it doesn't let me know.

    T

    : This link will give you the php info for my server:
    :
    : http://www.jamesa3.com/phpinfo.php
    :

  • I'm not sure I know how to do that. I had someone else set my php up for me. When I log in to my server I do not see any php folders except the phpMyAdmin for the MySQL database I am also running.
  • Maybe you can contact the server admin and ask for a little assistance? You can also set it yourself on a per-script or per-directory basis, but it would be better if you could reconfigure it entirely. I can't imagine why anybody would set that option to none.

    To set it within your script, use the ini_set function as follows:

    [code]
    ini_set("variables_order", "EGPCS");
    [/code]

    Give this a shot... let me know how it turns out.

    T


    : I'm not sure I know how to do that. I had someone else set my php up for me. When I log in to my server I do not see any php folders except the phpMyAdmin for the MySQL database I am also running.
    :

  • Still didn't work. I'll check with my server help. If you have the desire to, it would be valuable to me to know for sure that the code worked on another server. If you have a php server, perhaps you might try to run the two files from your server. An additional test might be to run the first file from your server and link it to the test5.php file on my server. Dispite that we haven't found the problem as yet, your willingness to help is greatly appreciated!!!!!!! Thanks.
  • By the way. I'm running Php 4.0.6. I don't know if this could also be a problem. Is this version able to pass variables in such a manner?
  • : By the way. I'm running Php 4.0.6. I don't know if this could also be a problem. Is this version able to pass variables in such a manner?
    :
    It should be...
    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...


  • [b][red]This message was edited by tvienti at 2005-7-21 9:33:26[/red][/b][hr]
    Actually... quoted from http://www.php.net/variables.predefined...

    [code]From version 4.1.0 onward, PHP provides an additional set of
    predefined arrays containing variables from the web server (if
    applicable), the environment, and user input. These new arrays are
    rather special in that they are automatically global--i.e.,
    automatically available in every scope. For this reason, they are often
    known as 'autoglobals' or 'superglobals'.[/code]

    That said, instead of $_GET try using $HTTP_GET_VARS, which should be the same thing. I've never used any of the $HTTP_*_VARS so I can't be sure but I believe they're identical copies of their counterparts. So $HTTP_GET_VARS is a copy of $_GET, $HTTP_POST_VARS is a copy of $_POST, etc.

    Reference:

    http://www.php.net/manual/en/reserved.variables.php

    Try using $HTTP_GET_VARS in your script and let me know if that works.

    T

    Edit: added line breaks in the php.net quote =)

    : : By the way. I'm running Php 4.0.6. I don't know if this could also be a problem. Is this version able to pass variables in such a manner?
    : :
    : It should be...
    : ;-)
    : -mac-
    : mailto:[email protected]
    : the Netherlands...
    :
    :
    :



  • I am afraid this code didn't work either. Did I enter the new code correctly?

    <?php
    $selection = $http_get_vars['selection'];
    print $selection;
    ?>

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories