What we really need to know is what the error is, I don’t see anything wrong with the first code that should cause an error. Turn on PHP debugging in WP so that hopefully you can see the real error. https://codex.wordpress.org/WP_DEBUG
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users