Turning a query string into an array after using parse_url
You need to use an associative array, e.g.

$pieces['query'] = array('q' =&gt; 'hello');


The arguments for l() are in no way related to, or compatible with, the return from parse_url(). To avoid confusion it'd be better to build up a separate options array to pass as the 3rd argument to l().