register_globals and $_SERVER['QUERY_STRING']

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deko

    register_globals and $_SERVER['QUERY_STRING']

    I use http variables with php - not sure if I've got the nomenclature
    correct, so here's an example of what I'm talking about:

    A navbar sends "somepage.php?s omevariable" when the link is clicked. The
    link looks like this:
    <a href='somepage. php?somevariabl e'>Some Page</a>

    Then I do stuff with "somevariab le" in PHP code.

    I understand that I need "register_globa ls = on" in my php.ini - but is
    there any other config, Apache or otherwise, that needs to be set up?

    I am not getting any value in $_SERVER['QUERY_STRING'];

    Why no value? Other troubleshooting ideas?

    Here's my server config:

    L = rh9 2.4.20-8
    A = apache 2.0.40-21
    M = mysql-3.23.54
    P = php4.2.2

    Thanks in advance.


  • Michael Fesser

    #2
    Re: register_global s and $_SERVER['QUERY_STRING']

    .oO(deko)
    [color=blue]
    >A navbar sends "somepage.php?s omevariable" when the link is clicked. The
    >link looks like this:
    ><a href='somepage. php?somevariabl e'>Some Page</a>
    >
    >Then I do stuff with "somevariab le" in PHP code.
    >
    >I understand that I need "register_globa ls = on" in my php.ini[/color]

    Why? It's off for good reasons. You may only need it for older or third-
    party scripts, not for newly written ones.
    [color=blue]
    > - but is
    >there any other config, Apache or otherwise, that needs to be set up?
    >
    >I am not getting any value in $_SERVER['QUERY_STRING'];
    >
    >Why no value? Other troubleshooting ideas?[/color]

    No idea at the moment, but if you need the posted variable - it's stored
    in $_GET['somevariable'].

    Micha

    Comment

    • deko

      #3
      Re: register_global s and $_SERVER['QUERY_STRING']

      > No idea at the moment, but if you need the posted variable - it's stored[color=blue]
      > in $_GET['somevariable'].[/color]

      Well, I'm not sure I understand. I don't know the value of 'somevariable' -
      how do I retreive it"

      Are you saying there is another way to get the value of a variable?
      Currently I am using:

      $nav = trim(strip_tags ($_SERVER['QUERY_STRING']));

      to retreive the value of variables passed thusly:

      <a href='services. php?services'>P rofessional Services</a>

      in this case, $nav = services

      If there is a better way to retreive the value of the variable, I would like
      to know. As for your suggestion with $_GET - can you give me an example?


      Comment

      • Michael Fesser

        #4
        Re: register_global s and $_SERVER['QUERY_STRING']

        .oO(deko)
        [color=blue][color=green]
        >> No idea at the moment, but if you need the posted variable - it's stored
        >> in $_GET['somevariable'].[/color]
        >
        >Well, I'm not sure I understand. I don't know the value of 'somevariable' -[/color]

        Ah, OK.
        [color=blue]
        >Are you saying there is another way to get the value of a variable?
        >Currently I am using:
        >
        >$nav = trim(strip_tags ($_SERVER['QUERY_STRING']));
        >
        >to retreive the value of variables passed thusly:
        >
        ><a href='services. php?services'>P rofessional Services</a>
        >
        >in this case, $nav = services[/color]

        Is it possible to change the link to something like

        <a href='services. php?name=value' >?

        Would make it much easier if you would know the name of the passed
        parameter.
        [color=blue]
        >If there is a better way to retreive the value of the variable, I would like
        >to know. As for your suggestion with $_GET - can you give me an example?[/color]

        URL-parameters are stored in the array $_GET, in the example above the
        array would contain an empty element named 'somevariable':

        Array
        (
        [somevariable] =>
        )

        You can use the key() function to get its name (assuming that there's
        only one parameter passed to the page):

        $nav = trim(strip_tags (key($_GET)));

        See <http://www.php.net/key>. But again: It would be easier with a name,
        especially if you want to pass more than one parameter:

        <a href='services. php?foo=this;ba r=that'>

        Then the $_GET array would be

        Array
        (
        [foo] => this
        [bar] => that
        )

        HTH
        Micha

        Comment

        • deko

          #5
          Re: register_global s and $_SERVER['QUERY_STRING']

          > Is it possible to change the link to something like[color=blue]
          >
          > <a href='services. php?name=value' >?[/color]

          Yes. I tried it and it works fine. The only reason I was using
          $_SERVER['QUERY_STRING']; was because of bad advice (that I paid $40/hour
          for)... !

          thanks for the help.


          Comment

          Working...