using urldecode() results in mysql error
===

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 my SQL 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.

Is urldecode not compatible with MySQL queries? I'm fairly certain it's an issue with the encode/decode, since I already tested my code with hard-coded info that bypassed the encode/decode, and it worked fine. Maybe the urldecode is somehow turning the characters into special ones that look the same but are internally different so MySQL can't read them?