WP database error for comments_popup_link()

Your template code includes $wpdb->print_error(). This function prints the last database error between [ and ] brackets, and the executed SQL code. But if there is no error, you just see the empty brackets and the SQL.

$wpdb->show_errors() is used to enable displaying of database errors. If you want to see all database errors, you can just call this function somewhere higher in your code (in your functions.php, or in a plugin). You probably only want to do this when you are in debug mode, so it would look like this:

if ( WP_DEBUG ) {
    $wpdb->show_errors();
}