insert category from form in a post

You need to create the category first, then add it to the post:

$my_post = array(); 
$my_post['post_author'] = $userid; 
$my_post['post_title'] = $name; 
$my_post['post_name'] = str_replace(' ', '-', $name);
$cat_id = wp_create_category($_POST['postcats'], 0); // we create the category and we get the ID, the 0 is for no parent category
$my_post['post_category'] = array($cat_id);//this value is an array not a single value 
$newpost_id= wp_insert_post( $my_post );

you can also just create the post and add the category later with wp_set_post_categories

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