Results 1 to 8 of 8

Thread: Variable Problem

  1. #1

    Thread Starter
    Lively Member Brandito's Avatar
    Join Date
    Nov 2000
    Location
    Here, There, Every Where!
    Posts
    106

    Variable Problem

    This is my problem.

    I have a url like this: test.php?myVar=Test

    ---- test.php -----
    ...
    echo "$myVar";
    ...
    ----------------------

    That should print out Test. But it does not.
    I can not get any of my variables pasted in from a url to work.
    I think there might some kind of php config file I need to mess with but I don't know what it would be. This is probably an older php 4 version on a windows box, running apache for windows...

    If anyone knows what might be going on here I would appriciate the help.

    Thanx,
    Brandito

    ps: I posted this q a few dayz ago but it must have been deleted or something 'cause I can't find it.
    Master of Cyber Fu - A Temple of Digital Chi

  2. #2
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    Try using

    echo $_GET['myVar'];

    alternativly, if you want the variable from forms, querystring, etc to be read into php variables, go to the php.ini file and change the register_globals.

    Hope this helps.

    (if it is coming from a form post, you can use $_POST['myVar'])

    the standard is to have register_globals off and use the global arrays to retrieve your data.

  3. #3

    Thread Starter
    Lively Member Brandito's Avatar
    Join Date
    Nov 2000
    Location
    Here, There, Every Where!
    Posts
    106

    Thanx

    Thanx allot!
    That is probably exactly what I am looking for.
    Master of Cyber Fu - A Temple of Digital Chi

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Also, if you have information that could be coming from POST or GET, you can use $_REQUEST, which holds both POST, GET and a handfull of others.

    As of PHP 4.2, register_globals is off by default, and it is now the "standard" method to use the superglobals.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    It is much easier to have "register_globals" set to on but is realllly not a good practice. i have just started using global methods now and it makes things a bit easier t understand when going through your code

    As of PHP 4.2, register_globals is off by default[/B]
    pissed me off to start with

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    They set it to off for security reasons, so I'm pretty sure it wasn't just flipping a coin that decided it.

    And it's also not much harder to type $_REQUEST['name']; than $name; Programmers are just too lazy these days.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Originally posted by The Hobo
    And it's also not much harder to type $_REQUEST['name']; than $name; Programmers are just too lazy these days.
    I'm lazy, thats why i'm trying to get out of the habbit now and do things properly

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I'm starting to be a hypocrit. *cleans up the pop cans all over his desk from the last month*
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width