First, make sure to add id=LAST_INSERT_ID(id) to the ON DUPLICATE clause, as noted at the bottom of the DOCS. The id in this case is the column name of your primary key (so in your case it may/may not be titled id).
http://stackoverflow.com/questions/15373308/pdo-lastinsertid-returns-0-when-using-on-duplicate-key-update