I recently uploaded a script and while it ran perfectly on my machine when I tried running it on the site it started generating the following error: Warning: Cannot modify header information - headers already sent by (output started at /home/[site]/public_html/nediting.php:14) in /home/[site]/public_html/nediting.php on line 224 (I removed the site's name from the directory path ) Im at a loss as apparently it's caused by blank spaces/lines outside the PHP code, except I don't have any.... Does anyone know what the hell is going on?
Show us the code above where header() is called. Hmm... are you sure your not echo'ing / printing out any html before the use of header() ?
Something has to be being sent to the browser before that header is called for you to be getting that error. Even a <title> or <meta> tag will not allow the header to be sent... even though you won't see anything on the page.
The fact that the script ran "perfectly" on your local machine is most probably simply because the PHP setting on your local machine is set not to display warnings (check the values for 'error_reporting') or not to display any errors at all (check 'display_errors', 'display_startup_errors') My suggestion is, trust the error message and check what is output on the line suggested. It may not be something you echo or print, but could also be another warning/notice/error message. Also, set your development environment to be as verbose as possible in reporting errors - so that you can notice small mistakes that may lead to bigger ones, and your production server as quiet as possible - to avoid it revealing sensitive info (e.g. file paths) that may open a security hole.
Put ob_start(); right after PHP start tag, as <? ob_start(); // remaining code goes here ?> PHP: Your problem will be solved
Ah, found out what the problem was. Just above line 14 there was some html code, whoops Thanks for the assisance though, I'll keep your suggestions in mind for next time
Also keep in mind that windows behaves differently to linux and production environments, when you're authoring stuff, it's a good idea to author on the OS you're going to use in production if possible, if not, open your php.ini and set all error reporting to the screen or logs so you know before you upload if something is wrong.