Hi, I'm trying to validate my website at http://validator.w3.org/, but keep on getting problems with url's. For example, this string http://www.amazon.com/s?ie=UTF8&keywords=Chase+Home+Equity+Loans&search-type=ss&index=blended&page=1 gets problems around the &k and &s bits. I've tried using urlencode to encode the whole string, or just the query string, but then the urls don't work. Does anyone know how to encode the url correctly?
Don't urlencode full url at once. Only query variable names and values need urlencode'ing. Path in url need to be rawurlencode'd. But this urlencoding is only needed when url path or querry vars contain characters that are not allowed there. To create valid html, just encode url using htmlspecialchars function.