You can't redirect a page after an error has been written. My guess is that your database connection is failing on line 9 which is causing an error message and then the redirect error is just a symptom. Are you sure your database information is correct and your database server is up and running?