My guess is that when the error reporting code was added you included a trailing space on the closing php tag, for example:
"?> "
instead of "?>"
a lot of times when the image is not uploading, it is because the form tag does not have the enctype="multipart/form-data" attribute, for example:
<form action="" method="post" enctype="multipart/form-data" id="form1">