I need to pass special symbols through the URL for my MySQL query. For example, I need to have a URL that is something like:

www.example.com/index.php?q=AND name LIKE '%hi%'

When I tried it at first, I got a 406 error. I looked it up and apparently I have to use urlencode() and urldecode() . I put those in, and the 406 error went away, but then I got a MySQL error:

mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Usually when I get these it means the query isn't written properly. So I echoed MySQL query, and everything looked fine. I even removed the urldecode() and hard-coded into a variable what I wanted to be passed to the page, and the MySQL error went away. However, both queries from using urldecode() and not using that are EXACTLY the same, so I'm kind of confused.

I went onto the php.net documentation page for urldecode() , and there was a warning that said something like using _GET and urldecode() together can result in unexpected things, and that _GET already functions as a decoder (or at least that's how I interpreted the wording), so I removed urldecode() but still left in the _GET , and that resulted in the text not being decoded, so I guess I didn't interpret the documentation correctly.