Super Easy PHP question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kemp
    Confirmed User
    • Feb 2001
    • 392

    #1

    Super Easy PHP question

    Why doesn't this work any more? (assuming the code is inside of test.php)

    <a href="test.php?table=oral">ORAL</a>

    <?
    print("$table");
    ?>

    It used to work for me on an older server. But now it says no variable is defined for $table when you click on the ORAL link. WTF?
  • azguy
    Confirmed User
    • Nov 2004
    • 5167

    #2
    globals is off. use $_GET["table"] instead

    Comment

    • StuartD
      Sofa King Band
      • Jul 2002
      • 29903

      #3
      Because on the new server, global variables are probably turned off.

      which means that if you pass something in the url, you have to get it like this:
      $_GET[table];

      and if you pass it in a form, it's like this:
      $_POST[table];
      This is me on facebook
      This is me on twitter

      Comment

      • Harmon
        ( ͡ʘ╭͜ʖ╮͡ʘ)
        • Mar 2004
        • 20012

        #4
        Correction. This is a "not so easy php question" now isn't it
        [email protected]

        Comment

        • kemp
          Confirmed User
          • Feb 2001
          • 392

          #5
          Thanks azguy - I knew it had to be something incredibly simple

          Comment

          • azguy
            Confirmed User
            • Nov 2004
            • 5167

            #6
            you can also turn on register_globals in your php.ini if you want

            Comment

            • fuzebox
              making it rain
              • Oct 2003
              • 22353

              #7
              Originally posted by azguy
              globals is off. use $_GET["table"] instead
              If you're lazy you can also use $_REQUEST if you don't feel like differentiating between _GET and _POST.

              Comment

              • kemp
                Confirmed User
                • Feb 2001
                • 392

                #8
                Dang, you guys post quick. lol

                Comment

                • kemp
                  Confirmed User
                  • Feb 2001
                  • 392

                  #9
                  Originally posted by fuzebox
                  If you're lazy you can also use $_REQUEST if you don't feel like differentiating between _GET and _POST.
                  Is there any speed differences (assuming this page will one day get 500k a day)?

                  Comment

                  • azguy
                    Confirmed User
                    • Nov 2004
                    • 5167

                    #10
                    Originally posted by kemp
                    Is there any speed differences (assuming this page will one day get 500k a day)?
                    you wouldn't feel it even if there was

                    Comment

                    • dubsix
                      Confirmed User
                      • Dec 2004
                      • 363

                      #11
                      Originally posted by fuzebox
                      If you're lazy you can also use $_REQUEST if you don't feel like differentiating between _GET and _POST.
                      I can't believe people still don't know abou register globals... it's been off in php by default for what 1+ year now?

                      Comment

                      • azguy
                        Confirmed User
                        • Nov 2004
                        • 5167

                        #12
                        Originally posted by WireSix-Ryan
                        I can't believe people still don't know abou register globals... it's been off in php by default for what 1+ year now?
                        Since v4.2.0, yeah.

                        Comment

                        • StuartD
                          Sofa King Band
                          • Jul 2002
                          • 29903

                          #13
                          Originally posted by WireSix-Ryan
                          I can't believe people still don't know abou register globals... it's been off in php by default for what 1+ year now?
                          uhmm... not everyone who deals with php is a programmer... and not all programmers have been working consistantly for years.

                          There's people out there who don't deal with a bunch of code day in and day out, they don't have to deal with this stuff. That's what diversity is all about.
                          This is me on facebook
                          This is me on twitter

                          Comment

                          Working...