I had a similar problem when I was starting out. Make sure you put quotes around anything that isnt a straight number, including text, dates, etc. Also, I find it very helpful to echo() all the variable snad the entire query before they are executed, so I can see exactly what is being passed into the SQL engine.