Solved it! I have to trim out the $_GET['q'] because that may causes spaces in the URL. Thanks everybody.