Use wp_set_post_terms() instead of wp_insert_post()

After some hours of further searching i found the solution:

wp_set_post_terms($pid, array("2"), "project-type");

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