2: Make sure that your column types (INT, VARCHAR, etc...) match what your trying to insert.
3: Change REPLACE INTO table VALUES ('$stuff');
-TO-
REPLACE INTO table (stuff) VALUES ('$stuff');
5: Change REPLACE INTO to UPDATE.
i.e.
UPDATE table SET value='$value';
-instead of-
REPLACE INTO table VALUES ('$stuff');