How to use escape characters (particularly #) with $_GET

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

    How to use escape characters (particularly #) with $_GET

    I don't have a lot of experience using $_GET.

    I need to know how to pass characters in using the $_GET method. The
    character I'm having a problem with right now is '#', but I'm sure
    there are others.

    Could anyone give me a list of characters that need to be escaped
    using $_GET, and then also how to use them?

    Also, could you tell me if any characters simply are not allowed in a
    get?

    Example:

    getData.php?typ e=edit&user=myN ame&item=Item#1

    Thanks,

    Chad

  • Jerry Stuckle

    #2
    Re: How to use escape characters (particularly #) with $_GET

    chad.a.morris@g mail.com wrote:
    I don't have a lot of experience using $_GET.
    >
    I need to know how to pass characters in using the $_GET method. The
    character I'm having a problem with right now is '#', but I'm sure
    there are others.
    >
    Could anyone give me a list of characters that need to be escaped
    using $_GET, and then also how to use them?
    >
    Also, could you tell me if any characters simply are not allowed in a
    get?
    >
    Example:
    >
    getData.php?typ e=edit&user=myN ame&item=Item#1
    >
    Thanks,
    >
    Chad
    >
    urlencode() your parameters.

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

    Comment

    • chad.a.morris@gmail.com

      #3
      Re: How to use escape characters (particularly #) with $_GET

      On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
      chad.a.mor...@g mail.com wrote:
      I don't have a lot of experience using $_GET.
      >
      I need to know how to pass characters in using the $_GET method. The
      character I'm having a problem with right now is '#', but I'm sure
      there are others.
      >
      Could anyone give me a list of characters that need to be escaped
      using $_GET, and then also how to use them?
      >
      Also, could you tell me if any characters simply are not allowed in a
      get?
      >
      Example:
      >
      getData.php?typ e=edit&user=myN ame&item=Item#1
      >
      Thanks,
      >
      Chad
      >
      urlencode() your parameters.
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstuck...@attgl obal.net
      =============== ===- Hide quoted text -
      >
      - Show quoted text -
      I'm trying to go from javascript (making the call) to php.

      For example:

      function getData()
      {
      var user = "user1" ;
      var item = encodeURI( "Item #1" ) ;
      xmlHttp.open( 'GET' , 'addData.php?us er=' + user + '&item=' +
      item ) ;
      }


      However, the encodeURI() function on the string give returns the
      following:

      Item%20#1

      So, it is leaving the pound sign, which is messing me up.

      Any other thoughts? Perhaps I'm not using the functions correctly?

      Thanks for the help!

      Chad

      Comment

      • Jerry Stuckle

        #4
        Re: How to use escape characters (particularly #) with $_GET

        chad.a.morris@g mail.com wrote:
        On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        >chad.a.mor...@ gmail.com wrote:
        >>I don't have a lot of experience using $_GET.
        >>I need to know how to pass characters in using the $_GET method. The
        >>character I'm having a problem with right now is '#', but I'm sure
        >>there are others.
        >>Could anyone give me a list of characters that need to be escaped
        >>using $_GET, and then also how to use them?
        >>Also, could you tell me if any characters simply are not allowed in a
        >>get?
        >>Example:
        >>getData.php?t ype=edit&user=m yName&item=Item #1
        >>Thanks,
        >>Chad
        >urlencode() your parameters.
        >>
        >--
        >============== ====
        >Remove the "x" from my email address
        >Jerry Stuckle
        >JDS Computer Training Corp.
        >jstuck...@attg lobal.net
        >============== ====- Hide quoted text -
        >>
        >- Show quoted text -
        >
        I'm trying to go from javascript (making the call) to php.
        >
        For example:
        >
        function getData()
        {
        var user = "user1" ;
        var item = encodeURI( "Item #1" ) ;
        xmlHttp.open( 'GET' , 'addData.php?us er=' + user + '&item=' +
        item ) ;
        }
        >
        >
        However, the encodeURI() function on the string give returns the
        following:
        >
        Item%20#1
        >
        So, it is leaving the pound sign, which is messing me up.
        >
        Any other thoughts? Perhaps I'm not using the functions correctly?
        >
        Thanks for the help!
        >
        Chad
        >
        Chad,

        First of all, it's urlencode() - not encodeURI(). I have no idea what
        that function does - it's not part of the PHP standard library.

        And you're using AJAX - which is something completely different. Not
        being an AJAX user myself, I can't say what your problem is. All I know
        is I use urlencode() with some regularity and it works fine. I've also
        tried strings with a '#' in them and it's OK.

        The '#' is used in an href to indicate a tag (<a name=...>) on a page.
        Perhaps AJAX is getting confused. I wouldn't know. Or maybe your
        encodeURI() function isn't doing the same thing.

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

        Comment

        • Erwin Moller

          #5
          Re: How to use escape characters (particularly #) with $_GET

          chad.a.morris@g mail.com wrote:
          On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          >chad.a.mor...@ gmail.com wrote:
          I don't have a lot of experience using $_GET.
          >>
          I need to know how to pass characters in using the $_GET method. The
          character I'm having a problem with right now is '#', but I'm sure
          there are others.
          >>
          Could anyone give me a list of characters that need to be escaped
          using $_GET, and then also how to use them?
          >>
          Also, could you tell me if any characters simply are not allowed in a
          get?
          >>
          Example:
          >>
          getData.php?typ e=edit&user=myN ame&item=Item#1
          >>
          Thanks,
          >>
          Chad
          >>
          >urlencode() your parameters.
          >>
          >--
          >============== ====
          >Remove the "x" from my email address
          >Jerry Stuckle
          >JDS Computer Training Corp.
          >jstuck...@attg lobal.net
          >============== ====- Hide quoted text -
          >>
          >- Show quoted text -
          >
          I'm trying to go from javascript (making the call) to php.
          >
          For example:
          >
          function getData()
          {
          var user = "user1" ;
          var item = encodeURI( "Item #1" ) ;
          xmlHttp.open( 'GET' , 'addData.php?us er=' + user + '&item=' +
          item ) ;
          }
          >
          >
          However, the encodeURI() function on the string give returns the
          following:
          >
          Item%20#1
          >
          So, it is leaving the pound sign, which is messing me up.
          >
          Any other thoughts? Perhaps I'm not using the functions correctly?
          Indeed.

          encodeURI leaves ; / ? : @ & = + $ , # all intact.

          What you need in Javascript is escape(), not encodeURI().

          Tip: Buy a good JS book and you never fall for this kind of thing again.
          I recommend Javascript, the definitive guide, by Flanagan (O Reilly)

          Regards,
          Erwin Moller
          >
          Chad

          Comment

          • chad.a.morris@gmail.com

            #6
            Re: How to use escape characters (particularly #) with $_GET

            On Mar 20, 11:20 am, Erwin Moller
            <since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
            chad.a.mor...@g mail.com wrote:
            On Mar 19, 8:45 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
            chad.a.mor...@g mail.com wrote:
            I don't have a lot of experience using $_GET.
            >
            I need to know how to pass characters in using the $_GET method. The
            character I'm having a problem with right now is '#', but I'm sure
            there are others.
            >
            Could anyone give me a list of characters that need to be escaped
            using $_GET, and then also how to use them?
            >
            Also, could you tell me if any characters simply are not allowed in a
            get?
            >
            Example:
            >
            getData.php?typ e=edit&user=myN ame&item=Item#1
            >
            Thanks,
            >
            Chad
            >
            urlencode() your parameters.
            >
            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstuck...@attgl obal.net
            =============== ===- Hide quoted text -
            >
            - Show quoted text -
            >
            I'm trying to go from javascript (making the call) to php.
            >
            For example:
            >
            function getData()
            {
            var user = "user1" ;
            var item = encodeURI( "Item #1" ) ;
            xmlHttp.open( 'GET' , 'addData.php?us er=' + user + '&item=' +
            item ) ;
            }
            >
            However, the encodeURI() function on the string give returns the
            following:
            >
            Item%20#1
            >
            So, it is leaving the pound sign, which is messing me up.
            >
            Any other thoughts? Perhaps I'm not using the functions correctly?
            >
            Indeed.
            >
            encodeURI leaves ; / ? : @ & = + $ , # all intact.
            >
            What you need in Javascript is escape(), not encodeURI().
            >
            Tip: Buy a good JS book and you never fall for this kind of thing again.
            I recommend Javascript, the definitive guide, by Flanagan (O Reilly)
            >
            Regards,
            Erwin Moller
            >
            >
            >
            >
            >
            Chad- Hide quoted text -
            >
            - Show quoted text -- Hide quoted text -
            >
            - Show quoted text -
            Thanks for the help Erwin and Jerry. I will definitely check out the
            book you mentioned. I'm finding that the more in depth that I go, the
            better off I'd be with a book.

            THANKS!!

            Comment

            Working...