wp_insert_attachment() dupplicate attachment posts

The cause was WPML settings which dupplicates media. :/

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)