Announcement

Collapse
No announcement yet.

Passing variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing variables

    I'm stuck!

    I wish to pass variables in my URLs and am having no success on my website hosting uk site, I have no problems with sites hosted by others

    To confuse me even further I know that the ?var=var is working on my blog which is from Wordpress

    I have a test page I can't give the URL, but it's in the code below

    The code is :

    <a href="http://www.warwickshire-photography.co.uk/test.php?var2=yes">YES</a><br>
    <a href='test.php?id=2489&user=tom'>link to page2</a><br>
    <a href="http://www.warwickshire-photography.co.uk/blog/?page_id=2">theirs</a><br>
    <?php
    echo "It returns $id <br>\n";
    echo "and $var2 <br> \n";
    echo "It returns $myvar <br> \n";
    echo "and $user <br> \n";
    ?>

    But it doesn't work - where is the obvious mistake?

    Many Thanks

    Jezzer

  • #2
    The code looks fine from the part you have given me. Are you sure it's not an error in the actual variable itself?

    Try and use the following, to test if it's at the variable level or the foreground.

    [PHP]
    <?PHP

    $id = "eyedee";
    $var2 = "varghtwo";
    $myvar = "mevarr";
    $user = "yooser";

    ?>

    <a href="http://www.warwickshire-photography.co.uk/test.php?var2=yes">YES</a><br>
    <a href='test.php?id=2489&user=tom'>link to page2</a><br>
    <a href="http://www.warwickshire-photography.co.uk/blog/?page_id=2">theirs</a><br>
    <?php
    echo "It returns $id <br>";
    echo "and $var2 <br>";
    echo "It returns $myvar <br>";
    echo "and $user <br>";
    ?>
    [/PHP]
    Webhosting.UK.com || cPanel VPS Hosting || Reseller Hosting

    Sales: 0808-262-0855
    Support: 0800-612-8725
    International: +44 191 303 8191

    Comment


    • #3
      Passing variables

      Thanks Dan

      I've checked that and am still getting the same result ?

      Jezzer

      Comment


      • #4
        Hi Jezzer,

        This will most likely result in a misconfigured PHP configuration, or a corrupt install of PHP as the code above works for me and outputs the variables.

        Example: http://sandbox.boldice.com/broken/duaujsgadsg.php

        I'd recommend contacting Livesupport through the relevant department, they should be able to resolve this in a few minutes for you. Apologies.
        Webhosting.UK.com || cPanel VPS Hosting || Reseller Hosting

        Sales: 0808-262-0855
        Support: 0800-612-8725
        International: +44 191 303 8191

        Comment


        • #5
          It is probably Register Globals.

          Try adding...
          "$id = $_GET['id'];"
          "$var2 = $_GET['var2'];"
          "$user = $_GET['user'];"
          "$page_id = $_GET['page_id'];"
          , etc, etc.

          Scottie.

          Comment


          • #6
            Fantastic

            Scottie

            Thanks, it works just fine

            Why do I need that when sites with other hosts do not?

            Comment


            • #7
              Originally posted by jezzer View Post
              Scottie

              Thanks, it works just fine

              Why do I need that when sites with other hosts do not?
              Hi jezzer,

              I'm glad you've got it working, I had the same problem when I moved to Webhosting which is why I recognised what was happening.

              Webhosting has register_globals turned off by default for security reasons, other providers set it on by default. You can turn it on through WHM's 'PHP Configuration Editor' but I wouldn't recomend it as it makes malicous attacks quite easy.

              Then again, I'm not a security expert so perhaps someone else can explain this better.

              Regards,

              Scottie

              Comment


              • #8
                Originally posted by scottie2212 View Post
                Hi jezzer,

                I'm glad you've got it working, I had the same problem when I moved to Webhosting which is why I recognised what was happening.

                Webhosting has register_globals turned off by default for security reasons, other providers set it on by default. You can turn it on through WHM's 'PHP Configuration Editor' but I wouldn't recomend it as it makes malicous attacks quite easy.

                Then again, I'm not a security expert so perhaps someone else can explain this better.

                Regards,

                Scottie
                register_globals off is a Good Thing.

                register_globals was a quick and dirty way to develop applications rapidly. In the early days this was fine but PHP has got so big that register_globals is now a huge security hole and is off by default in all new installations of PHP. As it will eventually be removed altogether this is a good opportunity to fix any dodgy code.

                If you need to know more see PHP: Using Register Globals - Manual
                black-dog
                4theweb.co.uk Web stuff
                slipperyhill.co.uk Band

                Comment

                Working...
                X