0

I created a login form on another server and it worked perfectly, now i transfered it to another server and im getting lots of new errors:

Warning: Cannot modify header information - headers already sent by (output started at /home/davethom/public_html/login.php:16) in /home/davethom/public_html/login.php on line 55

but the actual login works this message just appears, its probably just me being stupid and missing something,

www.scottechtrio.co.cc/login.html username: 1 password: 1

lewis
  • 19
  • 3
  • what was your `error_reporting();` set to on your last server? Set it to `error_reporting(0);` for none. – Sparkup Jul 27 '11 at 11:00
  • You also get `Warning: extract() [function.extract]: First argument should be an array in /home/davethom/public_html/priceupdate.php on line 65` on price update. – Sparkup Jul 27 '11 at 11:01
  • How do i edit the server settings? – lewis Jul 28 '11 at 13:50
  • at the top of your page put `error_reporting(0);` but that won't fix you problem it will just hide it. The opposite for debugging is `error_reporting(E_ALL);` – Sparkup Jul 28 '11 at 13:58

4 Answers4

4

You are probably calling the header() function, or another function that sends headers, like setcookie(), after starting sending some output.

Those functions must be called before any output is sent to the browser :

  • Before any echo / print is done,
  • Before any character (including white-spaces) outside of <?php ... ?> tags
Pascal MARTIN
  • 395,085
  • 80
  • 655
  • 663
1

Check for the whitespaces in your code. Remove the php closing tags (if any) at the end of your php page.

samir chauhan
  • 1,543
  • 1
  • 17
  • 42
0
  1. I think you need to turn off the display_errors directive in the php.ini file.
  2. If you are not able to edit php.ini file, call the following function on top of all your php files.

    ini_set('display_errors', 'Off');

You can also use .htaccess file in the webroot of your application with the following content.

php_flag   display_errors       Off
Poomalairaj
  • 4,888
  • 3
  • 23
  • 27
0

You shouldn't just turn off error reporting; you should fix your code so it doesn't cause any errors.

As stated by Pascal MARTIN, this error occurs when you call a function that sends an HTTP header after you have already sent output to the browser. session_start() sends a cookie header, so this (like header() and setcookie()) needs to be called before you output any content. Check line 55 in /home/davethom/public_html/login.php to find the offending function and make sure no content is sent to the browser before you call it.

Page content is anything sent to the browser to be rendered to the user. This could be your opening tags (or ) or even some errant whitespace, accidentally output somewhere. Look for echo or print statements, or anything not inside a set of delimiters (even just new lines or spaces here will be problematic).

As a debugging aid: to find out precisely what has been sent to the browser when this error occurs, put die(); immediately after line 55, visit the page in your browser, then use the browser to view the source it has received from the server so far.

See http://uk.php.net/manual/en/function.header.php for more information on incorrectly sending headers after content.

daiscog
  • 11,441
  • 6
  • 50
  • 62