in reply to SQL ERROR

Try printing out your $sql variable. It often makes errors much easier to see. (If not, then try posting the contents of $sql here).