[eluser]walterblaurock[/eluser]
Alternatively, you can simply take the contents of the query, and echo them as opposed to inputting them into the query function. Though not as elegant as the above solution, it can be useful as well. Are you using anything such as PHPMyAdmin that can give you specific feedback as to why a query isn't working (I'm assuming that is why you are outputting the query)? During debugging, I often echo the query and paste it into PHPMyAdmin in order to better understand what is going wrong.