How to make a sum of all posts displayed in a loop

If have_posts() is true, there is a global WP_Query object available. And that has a post count already:

if ( have_posts() )
{
    print $GLOBALS['wp_query']->post_count;
}

There is no need for a custom count.

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