Watch out for reserved words!

Q: What is the mistake in this MySQL snippet?

INSERT INTO table (key) = '$key';

A: In MySQL key is a reserved word, so you’ll always have to escape it:

INSERT INTO table (`key`) = '$key';
Advertisements