Improve mysql error handling

check for er_dup_entry when inserting values into database to check if
users are already friends.