Php Variable in HTML Link - Programmers Heaven

Howdy, Stranger!

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

Categories

Php Variable in HTML Link

jandrewsjandrews Posts: 30Member
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

  • mac_doggiemac_doggie Posts: 488Member
    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...


  • jandrewsjandrews Posts: 30Member
    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;
    ?>


  • tvientitvienti Posts: 230Member
    [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;
    : ?>
    :
    :
    :



  • jandrewsjandrews Posts: 30Member
    No results. I have also verified that my globals are on.
  • tvientitvienti Posts: 230Member
    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.
    :

  • mac_doggiemac_doggie Posts: 488Member
    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...


  • jandrewsjandrews Posts: 30Member
    This link will give you the php info for my server:

    http://www.jamesa3.com/phpinfo.php
  • tvientitvienti Posts: 230Member
    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
    :

  • jandrewsjandrews Posts: 30Member
    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.
  • tvientitvienti Posts: 230Member
    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.
    :

«1
Sign In or Register to comment.