There is a simple way to get rid of that problem - save player data with only 1 query. It seems that you first check if there is data in mysql and then use update or insert. You don't need to check if data of some player was previously inserted, because you should know that from loading and even if you don't know that, then you can just use REPLACE INTO and that will work as both insert and update (you just need to set authid as PRIMARY KEY when you create table).