Encoding html entities in url string
<p>I'm trying to prepare a url that has special characters in it, to be used as GET variables in a php file. I think I need html entities and urlencode, which I then need to decode in the other php file. But I'm running into some problems with correctly encoding them. 
This is what I have:</p>

<pre><code>&lt;?php $title = "This is a ‘simple’ test"; ?&gt;
&lt;?php $titleent = htmlentities($title); ?&gt;
&lt;?php $titleentencoded = urlencode($titleent); ?&gt;
&lt;?php $date = '21-12-2011'; ?&gt;

    &lt;p&gt;Title: &lt;?php echo $title; ?&gt;&lt;/p&gt;
    &lt;p&gt;Title html entities: &lt;?php echo $titleent; ?&gt;&lt;/p&gt;
    &lt;p&gt;Title encoded: &lt;?php echo $titleencoded; ?&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href="index.php?title=&lt;?php echo $titleencoded; ?&gt;&amp;date=&lt;?php echo $date; ?&gt;"&gt;Go!&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>The $titleencoded variable turns out to be empty. I'm overlooking something obvious but I can't see it. What am I doing wrong?</p>

<hr>

<p><strong>EDIT:</strong> New code after suggestions</p>

<p>Okay, so here's what I came up with: </p>

<pre><code>&lt;?php $title = "This is a ‘simple’ test"; ?&gt;
&lt;?php $titleentencoded = urlencode($title); ?&gt;
&lt;?php $htmlent = htmlentities($titleentencoded); ?&gt; 
&lt;?php $date = '21-12-2011'; ?&gt;

&lt;p&gt;Title: &lt;?php echo $title; ?&gt;&lt;/p&gt;
&lt;p&gt;Title encoded: &lt;?php echo $titleentencoded; ?&gt;&lt;/p&gt;
&lt;p&gt;Title html entities: &lt;?php echo $htmlent; ?&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="index.php?title=&lt;?php echo $htmlent; ?&gt;&amp;date=&lt;?php echo $date; ?&gt;"&gt;Go!&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>Is this the right way?</p>
