wp_insert_post insert a post but return 0

I found the answer. Actually I was passing the template in the wp_insert_post.

When I remove that parameter it returns the post ID. And with that post ID I used

add_post_meta( $page_id, '_wp_page_template', 'tpl-favourites.php' );

to set the template for that page. It is a common technique. I have just dig the code of a standard theme.

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