You can't print or echo anything prior to using the header function. This is because any time you use print or echo you are causing the response headers of the page to be sent to the user. Print and echo are actually writing to a stream so when you start writing it sends the headers of the page, making it too late to modify the headers using the header() function.
To solve this make sure you do not print ANYTHING prior to making a header() call. This means no printing or echoing any spaces, tabs, lines or anything which would cause the headers of the page to be sent.
So to fix your code, comment out the echo line and if you have no other echos previous to this code, it should work fine.
You can read up on this more at php.net for the header() function.
Hope this helps you out!
"At DIC we be header sending code ninjas... no I said 'heading'! Get your mind out of the gutter"