Function to display post by specific author

Here is how I would solve your problem since $authordata is not a variable that I recognize as a WordPress global.

function display_post_via_specific_author( $nicename ) {
    // Grab the user by `user_nicename`
    $author = get_user_by( 'slug', $nicename );

    $posts = get_posts( 
        array(
            'author' => $author->ID, 
            'posts_per_page' => 5
        )
    );

    $output="<h5>Latest Posts by Sam</h5>";
    $output .= '<ul>';
    foreach ( $posts as $post ) {
        $output .= '<li><a href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a></li>';
    }
    $output .= '</ul>';

    return $output;

}

So it should be easy to query by author login calling the function like this:

echo display_post_via_specific_author( 'nick' );

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