<HTML dir=ltr><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6001.18099" name=GENERATOR></HEAD>
<BODY>
<P><FONT face=Verdana size=2>Hi,</FONT></P>
<P><FONT face=Verdana size=2>I hope this list is still running - I haven't received anything in a few days now.</FONT></P>
<P><FONT face=Verdana size=2>I am new to Drupal and am struggling to work out when I should use drupal_urlencode() and when I should use urlencode(). And is there a urldecode()? I cant find one.</FONT></P>
<P><FONT face=Verdana size=2>The exact problem I have has to do with putting a filename into a URL as a request parameter. This was being put into a URL without any encoding and worked fine until someone added a file with an &amp; in the name. So I looked into drupal_urlencode(), but it seems to not work, while urlencode() works perfectly.</FONT></P><FONT face=Verdana size=2>
<P><BR>When I use drupal_encode():<BR>---------------------------</P>
<P>$filename = 'Arm&amp;Hammer.jpg';</P>
<P>$req_param = drupal_urlencode($filename)</P>
<P>The URL for the link produced is:<BR><A href="http://www.xyz.com/download.php?filename=Arm%2526Hammer.jpg">http://www.xyz.com/download.php?filename=Arm%2526Hammer.jpg</A></P>
<P>And when I extract the parameter in download.php and use it I get the following error message:</P>
<P>warning: fopen(C:\Program Files\Apache Software Foundation\Apache2.2\drupal_files/images/Arm%26Hammer.jpg) [function.fopen]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\download.php on line 10.</P>
<P><BR>When I use urlencode():<BR>-----------------------</P>
<P>$req_param = urlencode($filename)</P>
<P><A href="http://www.xyz.com/download.php?filename=Arm%26Hammer.jpg">http://www.xyz.com/download.php?filename=Arm%26Hammer.jpg</A></P>
<P>download.php is able to extract the request parameter and open the file.</P>
<P><BR>Can someone please explain to me when I should be using drupal_urlencode() and when I should use urlencode().</P>
<P>Thank you</P>
<P>robin</FONT></P>
<DIV id=idOWAReplyText901 dir=ltr>
<DIV dir=ltr><STRONG><FONT face=Verdana size=2></FONT></STRONG>&nbsp;</DIV></DIV></BODY></HTML>
<pre>**************************************************************************************************************************************************************** 

The content of this email (and any attachment) is confidential. It may also be legally privileged or otherwise protected from disclosure. 

This email should not be used by anyone who is not an original intended recipient, nor may it be copied or disclosed to anyone who is not an original intended recipient. 

If you have received this email by mistake please notify us by emailing the sender, and then delete the email and any copies from your system. 

Liability cannot be accepted for statements made which are clearly the senders own and not made on behalf of Network Rail. 

Network Rail Infrastructure Limited registered in England and Wales No. 2904587, registered office Kings Place, 90 York Way London N1 9AG 

****************************************************************************************************************************************************************