I always used to dread SQL statements because of the ticks and the quote marks and all that jazz. I did find though (and this may be common knowedge, so forgive me if I'm being too simplistic) that it's really useful to use the escape character ([/b]) when forming SQL statements, and to avoid using "ticks" at all.
eg
$sql = "select * from table where text = \"".$text."\"";
which may look no different or may look very confusing, but what it does is because you've escaped the first " with the \ character, PHP simply outputs it as opposed to intepreting it: that way, if you were to echo $sql later (and had set $text = "search string" for example) it would read:
select * from table where text = "search string"
It's handy because i've found having the quotes in the sql statement make for less errors when you try to ass stuff in there (when i surrounded them with ticks i was forever trying to avoid entering an apostrophe into my search strings etc).
If that doesnt make any sense then please say so and i'll try again, but i;d strongly suggest trying it in your code - just be careful to remember which quotes you want escaped and which ones you dont - it can be quite confusing when you look at it later on!