简体   繁体   中英

header redirection error due to headers already sent at line

I am using header redirection but it not seems to be working for me it was before it suddenly stopped. I googled it and found out that headers already sent is a possible reason for those. I have tried a number of solutions but none of them worked for me. Here's the initial code (it's not the full code because my errors are up until the end of this code, not afterwards)

<?php ini_set('display_errors',1);error_reporting(E_ALL);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script>
     var price="";
    var check=new Array();
    </script>
    <style>

    <!--code for removing spinner-->
    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    input[type=number] {
        -moz-appearance:textfield;
    }
    <!--code for removing spinner-->

    </style>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Cart</title>
    <link rel="stylesheet" type="text/css" href="engine1/style.css" />
    <link rel="stylesheet" href="css/bootstrap.css" />
    <link rel="stylesheet" href="css/mystyle.css"  />
    <link rel="stylesheet" href="css/responsive.css"  />
    <script type="text/javascript" src="engine1/jquery.js"></script>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
</head>

<body class="loading">
    <div class="wrapper">   
         <?php $pagename="cart";
             include("inc/header.php"); ?>
            <div class="faq-bg cartbg">
                <h1>Your cart</h1>
            </div>
        <?php   
/////////////////////////db is initialized in this class manually
//session_start();
    unset($_SESSION['address1-session']);
    unset($_SESSION['address1-2-session']);
    unset($_SESSION['city1-session']);
    unset($_SESSION['state1-session']);
    unset($_SESSION['postalcode1-session']);
    unset($_SESSION['address2-session']);
    unset($_SESSION['address2-2-session']);
    unset($_SESSION['city2-session']);
    unset($_SESSION['state2-session']);
    unset($_SESSION['postalcode2-session']);
    unset($_SESSION['puppy_name-session']);
    unset($_SESSION['puppydate-session']);
    unset($_SESSION['error']);
    unset($_SESSION['flag']);
    unset($_SESSION['unique_id']);
    unset($_SESSION['flagshipping']);
    //unset($_SESSION['sess_user']);
    unset($_SESSION['quantity']);
    unset($_SESSION['bundleplan']);
    unset($_SESSION['dogsize']);
    unset($_SESSION['extrapuppy']);
    unset($_SESSION['toycount']);

Here's the url of the project I am working on so you can see the error.

This normally can be resolved by a quick custom .user.ini alteration:

1) Create a custom .user.ini file (if there isn't one already)

2) Locate the line that looks like:

output_buffering = Off

3) Change the output_buffering line to:

output_buffering = On

This should be all that is needed to bring the site back online.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM