How to create an array for a CPT post ID to use in an IF/WHILE statement

You can use the fields parameter of WP_Query to get just IDs back, then iterate over them with a foreach loop:

$args = array(
    'post_type' => 'services',
    'posts_per_page' => -1,
    'fields' => 'ids',
);
$query = new WP_Query( $args );

if( $query->have_posts() ){
    foreach( $query->posts as $id ){
        the_field( 'the_field', $id );
    }
} else {
    echo 'There are no services';
}

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