How to give all CPT a folder automatically based on their slug

Your second function is wrong. get_post_type($post) excepts the current post object or post ID or any post object or ID given to it. You are using the arguments for get_post_types( $args, $output, $operator ) for get_post_type, which fails the function which in turn gives you the error in your foreach loop.

To rectify your function, use something like this:

add_filter('single_template', 'my_single_template_folders_terms');
function my_single_template_folders_terms($template) {
    global $post;

    $post_type = get_post_type($post);
    if ( file_exists(TEMPLATEPATH . "/{$post_type}/single.php") )
        return TEMPLATEPATH . "/{$post_type}/single.php";

    return $template;
}

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