1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Please Help with Validation of "&" in PHP URL's

Discussion in 'PHP' started by you-cubez, Feb 22, 2007.

  1. #1
    Hi there - I have a website selling advertising and a customer has an affiliate link with PHP in the URL. Now... when I come to validate it (http://validator.w3.org), obviously it tells me it needs to be "&" but this then stops the URL functioning. Does anyone know what you need to do to ensure it is XHTML 1.0 validated?

    Thanks guys! :)
     
    you-cubez, Feb 22, 2007 IP
  2. lmoss

    lmoss Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you sure about that? If I post the following URL on DigitalPoint, the forum software will replace the & by an & (look at the page source) and the URL will still work properly:

    http://www.google.ca/search?hl=en&q=test
     
    lmoss, Feb 22, 2007 IP
  3. you-cubez

    you-cubez Active Member

    Messages:
    842
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Yes - but that will not be Valid XHTML 1.0 - Please visit www.you-cubez.com - and in the bottom right hand corner I have "valid XHTML 1.0 | Valid CSS" - Click the XHTML 1.0 link you will see what I mean.

    Thanks for your help
     
    you-cubez, Feb 22, 2007 IP
  4. lmoss

    lmoss Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I saw what you mean, but I maintain that the link I posted above is valid XHTML. If you look at this thread's page source, you will see that above link has the following HTML:

    <a href="http://www.google.ca/search?hl=en&amp;q=test" target="_blank">http://www.google.ca/search?hl=en&amp;q=test</a>
    Code (markup):
    So there is an &amp; in the HTML source and the browser still processes the URL correctly.

    A validation of this thread page shows various XHTML errors, but none relating to an "&" in an URL: http://validator.w3.org/check?uri=http://forums.digitalpoint.com/showthread.php?t=251174
     
    lmoss, Feb 22, 2007 IP
  5. you-cubez

    you-cubez Active Member

    Messages:
    842
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Hmm... Well W3 cannot validate my code with '&' in the PHP URL... there must be a way around it though...
     
    you-cubez, Feb 26, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    The solution has been posted twice now. It's not that hard. :(

    Replace all & with &amp; in your source code and the problem is fixed.
     
    nico_swd, Feb 26, 2007 IP