1

i have php code which was working in Mavericks, then i updated my system to Yosemite, apache 2.4.9 (unix) is installed in yosemite, now when i run my code, i got this error:

Warning: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/odnoklasniki/indexSingle.php:10) in /Library/WebServer/Documents/odnoklasniki/indexSingle.php on line 125

in 125 line, i have this code:

header('Location: http://www.odnoklassniki.ru/oauth/authorize?client_id='.$AUTH['application_key'].'&scope=PHOTO_CONTENT&response_type=code&redirect_uri=http://localhost/odnoklasniki/indexSingle.php');

before it was working in mavericks.

Code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link href="http://www.odnoklassniki.ru/oauth/resources.do?type=css" rel="stylesheet">
</head>
<body>

<?php
    if (statement true) {
        **** // i have some echo's here, i tried by removing them
    } else {
        header('Location: http://www.odnoklassniki.ru/oauth/authorize?client_id='.$AUTH['application_key'].'&scope=PHOTO_CONTENT&response_type=code&redirect_uri=http://localhost/odnoklasniki/indexSingle.php');
    }
?>

</body>
</html>
kakajan
  • 2,614
  • 2
  • 22
  • 39
  • 1
    possible duplicate of [How to fix "Headers already sent" error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Cheery Nov 20 '14 at 06:38

2 Answers2

1

You might have used echo or html code before the header(),

Do not use/render any echo or html code before the header(), and if there any thing remove all and try, which will work.

output started at /Library/WebServer/Documents/odnoklasniki/indexSingle.php:10

see this lines and remove the echo/ blank spaces/ html etc.

Ashique C M
  • 733
  • 4
  • 8
0

You probably output something before the PHP header command, that's the cause of the error you get. You can use a die(); function before this line and call the page from the browser, you will probably see the output sent before the header() command.

Vasilis Lourdas
  • 1,179
  • 1
  • 16
  • 35