The only "duplication" which isn't allowed is having multiple id attributes with the same value within one document.
In 4.01 (which is pretty much irrelevant since some/most/all current browsers treat documents as HTML 5 no matter what DTD you specify since HTML 5 doesn't actually make use of a DTD but rather follows specific parsing rules):
If the target anchor is an a element, then it should have the fragment identifier as its name attribute value. For any other element, the id attribute should be used.
There are several very good reasons for NOT using a elements as the target of links with fragment identifiers.
If you want to use the CSS pseudo-class :target to alter the presentation of the target element to set it apart (different background color, color, border etc), then using an empty a element before the actual content will not work, since the empty element is the target. However, if you have the element containing the content as the target, then it will work, such as <div id="fragtarget">content</div>
HTML 5 (applies to HTML mime types only. for XHTML, see RFC 3023 section 5) traverses the DOM tree to find an exact match for the fragid (assuming non-empty string) against the id attributes, breaking on first encountered match (there should be only one match since it's not allowed to have multiple ids with the same value). If this fails, the process is repeated against the name attribute.
The anchor element does not have a name attribute in HTML 5
In HTML 4.01, all but the a element should have the fragid in the id attribute
The id attribute has to be unique
And here's my example code which works perfectly in IE9, so I have no idea what goes wrong for you from what I've seen.
header('location: http://example.com/file.html?upload_message=image%20uploaded#gallery');
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style type="text/css">
html
{
font-size: 1em;
}
body
{
font-size: 0.8em;
width: 120px;
}
*:target
{
background-color: #CCC;
}
</style>
</head>
<body>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p id="gallery">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</body>
</html>