Show custom field on attachment page?

If this is related to your other question then the custom field is attached to the post and not the attachment. You need to get the post ID of the post first then you can get the custom field. This should work.

global $wp_query;
$attachment_id = $wp_query->post->ID;
$parent_id = get_post_field('post_parent', $attachment_id);

echo get_post_meta($parent_id, 'my_custom_field', true);

error code: 523