Function to list posts from current post’s category fails in WP 3.8

I never found out what stopped the function from working with WP 3.8, but I found that this variant of it does work – and I have no idea why:

<?php
function list_posts_from_current_category() {
if(is_single()){
$tempArray = get_the_category($post->ID);
$FirstCatName = $tempArray[0]->slug;
$this_post = get_the_ID();
$PostsPerPage = 5;
query_posts(array('category_name' => $FirstCatName, 'post__not_in' => array($this_post), 'posts_per_page' => $PostsPerPage, 'orderby' => 'rand'));
while ( have_posts() ) : the_post();
$ThisPermalink = get_permalink();
$ThisTitle = get_the_title();
echo "https://wordpress.stackexchange.com/questions/126571/<a href="<a href="#">ThisPermalink</a>">'.$ThisTitle.'</a><br />';
endwhile;
wp_reset_query();
}
}
add_action('do_my_list', 'list_posts_from_current_category');
?>

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