Warning: Cannot modify header information - headers already sent by (output star

Dear PHP HELP,

i am having the following error in my website www.flowersmanama.com please check the website:
Warning: Cannot modify header information - headers already sent by (output started at
i made many search but i wasn’t able to solve it…
will you please guide me?

[php]<?php
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.flowersmanama.com”);
?> [/php]

[code]<?
session_start();
// Include MySQL class
require_once(‘inc/mysql.class.php’);
// Include database connection
require_once(‘inc/global.inc.php’);
// Include functions
require_once(‘inc/functions.inc.php’);
?>

<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.flowersmanama.com"); ?> <? include("includes/title.php") ?> <? include("includes/keywords.php") ?> .......... ......... ............[/code]

the problem might be on www.flowersmanama.com not your headers

what do you mean? so how can i found the error?

These two lines in your code not make sense:

header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.flowersmanama.com");

First, you’re outputting part of HTML page, and then suddenly making redirect.
If you want to redirect to another page, these two lines must be above any HTML code in your php script, like this:
[php]<?
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.flowersmanama.com”);
?>

[/php]

When i put the code at the top of the file, the way you told me, the website is not opening:

The page isn’t redirecting properly

      Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept
cookies.

any other suggestions?

You seem to have resolved this issue? site checks out ok now. What was your solution?

No it is not, i am still trying…
when you checked the website i removed the code…
still not solved…
i am trying to add the following code:

[php]

<?php function currentPageURL() { $curpageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$curpageURL.= "s";} $curpageURL.= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $curpageURL.= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $curpageURL.= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $curpageURL; } $FullUrl = currentPageURL(); if ($FullUrl = "http://flowersmanama.com/") { Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.flowersmanama.com/" ); } ?>[/php]

IT IS WOKING NOW With the following code:


<?
session_start();
function currentPageURL() {
    $curpageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") {$curpageURL.= "s";}
    $curpageURL.= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
    $curpageURL.= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
    $curpageURL.= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $curpageURL;
    }

    $FullUrl = currentPageURL();
    $url ="http://flowersmanama.com/";
    if ($FullUrl == $url)
        {
                Header( "HTTP/1.1 301 Moved Permanently" );
                Header( "Location: http://www.flowersmanama.com/" );  
                               
        }

I am confused what is the Old url/page and what is the new URL.

If I am reading this correctly your issuing a 301 error for that page then forwarding right back to that page. It cannot be Permanently moved and at the same url.

That’s what i’m reading as well. If you’re just adding the www part, you can do that with .htaccess rather than a whole script

Please hit the solved button at the bottom of the page if you have a solution please.

Sponsor our Newsletter | Privacy Policy | Terms of Service