check if page have children, but not attachment

You should specify the post_type for the get_children() function, which can be one of attachment, page, revision or any and considered to be any by default:

$children = get_children( array( 'post_parent' => get_the_ID(), 'post_type' => 'page' ) );

error code: 523