i guess it's all the same thing, but the original code just had single quotes inside single quotes which seemed to be the problem, so you could really just use double quotes like in red's last example and shouldn't have to escape the single quotes after that.
backticks arouind table names is proper i believe, but i haven't found that they are necessary unless you have a table name with spaces ( i think )
i'm too lazy to check, but if you escape single quotes when they don't need to be escaped, will that generate an error?
most of my queries are formatted in this style:
PHP Code:
$query="SELECT * FROM memfiles WHERE field = '{$field}' ";