Registered access area

Ok i solved with this way:

        // Redirect guest users
    function login_redirect() {
        global $pagenow; 
        // If user is not loged in and not in the login page
        if(!is_user_logged_in() && $pagenow != 'wp-login.php')
              auth_redirect();
    }
    add_action( 'wp', 'login_redirect' );

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