Why is my custom form saving with ‘autodraft’ as title and slug?

Ok, so after reading the codex page on the ‘save_post’ hook, I spotted that they use a different way of dealing with revisions. So removing the if {...} surrounding the wp_update_post( $posttitle ) and inserting the following code fixed my problem:

if ( $post = wp_is_post_revision( $post ) )
        $post = $post; 

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