SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot charles_i's Avatar
    Join Date
    Apr 2007
    Location
    Toronto, Canada
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I escape an equals sign in a URL?

    I have a tracking code that uses equal signs to capture the edition number and page address in a URL. Problem is a URL that has an equal sign - everything after the URL is dropped because PHP thinks it's a variable - but it's not. How do I escape it?

    Thanks
    Charles

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Charles I have never seen a valid URL that contained an equal sign other than in a query value. Could you pleae post an example ?
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Zealot charles_i's Avatar
    Join Date
    Apr 2007
    Location
    Toronto, Canada
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are loads of them out there - including the link to this post

    http://www.sitepoint.com/forums/show...18#post3505118

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That link contains a query value which has an equal sign. The URL itself does not have an equal sign in it! Any value after the "?" is a query value and can be retrieved using the $_GET variable with the proper index.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  5. #5
    SitePoint Zealot charles_i's Avatar
    Join Date
    Apr 2007
    Location
    Toronto, Canada
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, the problem is that the link I am working with has its own PHP in it which is being truncated by my PHP. Code is like this:


    http://.../.../redir?issue=City&url=...?siteurl=sales

    I am only using the $_GET variable for "issue" and "url" - but when this goes from the email to my PHP page the URL ends after "siteurl" - no "=sales" because my PHP thinks it's a variable but it's not mine so I want it left intact.

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried the parse_url() function ? You can specify the "PHP_URL_QUERY" parameter and get the query fragment as a string. You can then use the explode function and parse out the url value yourself. Oh by the way, if the parse_url() function returns a false this would indicate a malformed url. Should this be the case you might want to rethink your query value structure.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


Bookmarks

Posting Permissions

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