Log in

View Full Version : php urlencode



JasonDFR
12-22-2008, 05:33 PM
<p><a href="http://<?php echo urlencode("maps.google.fr/maps?f=q&hl=fr&geocode=&q=limoges&sll=47.15984,2.988281&sspn=19.97465,57.128906&ie=UTF8&z=11&g=limoges&iwloc=addr"); ?>">Limoges</a> : <?php echo jd_time(); ?></p>

This results in a hyperlink that does not work:

Address Not Found

Firefox can't find the server at maps.google.fr%2fmaps%3ff%3dq%26hl%3dfr%26geocode%3d%26q%3dlimoges%26sll%3d47.15984%2c2.988281%26sspn%3d19.97465%2c57.128906%26ie%3dutf8%26z%3d11%26g%3dlimoges% 26iwloc%3daddr.

The browser could not find the host server for the provided address.

* Did you make a mistake when typing the domain? (e.g. "ww.mozilla.org" instead of "www.mozilla.org")
* Are you certain this domain address exists? Its registration may have expired.
* Are you unable to browse other sites? Check your network connection and DNS server settings.
* Is your computer or network protected by a firewall or proxy? Incorrect settings can interfere with Web browsing.

What am I doing wrong?

Thanks.

Medyman
12-22-2008, 06:01 PM
Change the ampersands to their HTML entity equivalent.

So, & becomes &amp;.

JasonDFR
12-22-2008, 06:12 PM
Thanks.

I only posted in the PHP form after realizing this might be a PHP problem rather than a HTML. Changing urlencode to htmlentities works. Thanks.