Why won't variable echo?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • affiliateian@gmail.com

    #1

    Why won't variable echo?

    Just moved web hosts and noticed that this:

    <?php echo "$f"; ?>

    used to work when there was an ?f= in the URL like so:


    Now it doesn't at the new host.

    I want to echo out "yes" in the HTML.

    Any ideas?

    TIA.

  • Chris Hope

    #2
    Re: Why won't variable echo?

    affiliateian@gm ail.com wrote:
    Just moved web hosts and noticed that this:
    >
    <?php echo "$f"; ?>
    >
    used to work when there was an ?f= in the URL like so:

    >
    Now it doesn't at the new host.
    >
    I want to echo out "yes" in the HTML.
    >
    Any ideas?
    register_global s will be off on your new host.

    Either enable it using .htaccess (if possible) or change all references
    to eg echo $_GET['f']. The latter is the better option but if your site
    is full of global references then as a short term solution you'll need
    to get register_global s enabled.

    More info here: http://nz.php.net/register_globals

    --
    Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

    Comment

    • affiliateian@gmail.com

      #3
      Re: Why won't variable echo?

      Chris Hope wrote:
      Either enable it using .htaccess (if possible) or change all references
      to eg echo $_GET['f']. The latter is the better option but if your site
      is full of global references then as a short term solution you'll need
      to get register_global s enabled.
      Thanks Chris, not sute how to enable register_global s but echo
      $_GET['f'] worked! Thanks so much!

      Comment

      • Rik

        #4
        Re: Why won't variable echo?

        affiliateian@gm ail.com wrote:
        Chris Hope wrote:
        >Either enable it using .htaccess (if possible) or change all
        >references to eg echo $_GET['f']. The latter is the better option
        >but if your site is full of global references then as a short term
        >solution you'll need to get register_global s enabled.
        >
        Thanks Chris, not sute how to enable register_global s but echo
        $_GET['f'] worked! Thanks so much!
        Luckily.

        Either make sure sure ALL your values are initialiased ($f = '' etc...),
        or keep register_global s off (preferably both ofcourse), so your script
        won't have to deal with variable values that have been set by a user on the
        Evil Net, but only by youself, or a validated/checked request from the
        user. That way you're reaonably sure what your sript does, instead of
        intorducing unpredictable, and potentially harmfull, variables.
        --
        Rik Wasmus


        Comment

        • aeg

          #5
          Re: Why won't variable echo?


          affiliateian@gm ail.com wrote:
          Just moved web hosts and noticed that this:
          >
          <?php echo "$f"; ?>
          >
          used to work when there was an ?f= in the URL like so:

          >
          Now it doesn't at the new host.
          >
          I want to echo out "yes" in the HTML.
          >
          Any ideas?
          >
          TIA.
          Just at tip, for security reasons you may want to addslashes ie
          addslashes($_GE T['f]) else people could inject into your site.

          Comment

          • Jerry Stuckle

            #6
            Re: Why won't variable echo?

            aeg wrote:
            affiliateian@gm ail.com wrote:
            >
            >>Just moved web hosts and noticed that this:
            >>
            >><?php echo "$f"; ?>
            >>
            >>used to work when there was an ?f= in the URL like so:
            >>http://www.mydomain.com/index.html?f=yes
            >>
            >>Now it doesn't at the new host.
            >>
            >>I want to echo out "yes" in the HTML.
            >>
            >>Any ideas?
            >>
            >>TIA.
            >
            >
            Just at tip, for security reasons you may want to addslashes ie
            addslashes($_GE T['f]) else people could inject into your site.
            >
            Addslashes won't do a thing here - except maybe screwup the output he's
            echoing.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Shelly

              #7
              Re: Why won't variable echo?


              "Chris Hope" <blackhole@elec trictoolbox.com wrote in message
              news:4536c656@n ews.orcon.net.n z...
              affiliateian@gm ail.com wrote:
              >
              >Just moved web hosts and noticed that this:
              >>
              ><?php echo "$f"; ?>
              >>
              >used to work when there was an ?f= in the URL like so:
              >http://www.mydomain.com/index.html?f=yes
              >>
              >Now it doesn't at the new host.
              >>
              >I want to echo out "yes" in the HTML.
              >>
              >Any ideas?
              I have made it a habit to always write something like that as:

              <?php echo '"' . $f . '"'; ?>

              or

              <?php echo $f; ?>

              and I always say <?php


              (single-double-single quotes)

              Shelly


              Comment

              • aeg

                #8
                Re: Why won't variable echo?


                Jerry Stuckle wrote:
                aeg wrote:
                affiliateian@gm ail.com wrote:
                >Just moved web hosts and noticed that this:
                >
                ><?php echo "$f"; ?>
                >
                >used to work when there was an ?f= in the URL like so:
                >http://www.mydomain.com/index.html?f=yes
                >
                >Now it doesn't at the new host.
                >
                >I want to echo out "yes" in the HTML.
                >
                >Any ideas?
                >
                >TIA.

                Just at tip, for security reasons you may want to addslashes ie
                addslashes($_GE T['f]) else people could inject into your site.
                >
                Addslashes won't do a thing here - except maybe screwup the output he's
                echoing.
                >
                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===
                He's relying on data from the url though, this could be dangerous
                unless processed correctly

                Comment

                Working...