-1

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.

ekad
  • 14,436
  • 26
  • 44
  • 46
uneeb
  • 89
  • 1
  • 11
  • 4
    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) – u_mulder Sep 20 '16 at 11:44
  • i have studied that url before anything i have remove many issues related to mine but still it is giving me that error – uneeb Sep 20 '16 at 11:46
  • i had but none of those situation seems to be working for me – uneeb Sep 20 '16 at 11:46
  • they are just warning you gets because you used variables without init them so remove line warnings will be disappear if not then put only error_reporting(0); – Abhijit Jagtap Sep 20 '16 at 11:47
  • its just a warning you can turn it off by changing `error_reporting(E_ALL);` to this `error_reporting(E_ERROR);` to keep only **Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.** – Noman Sep 20 '16 at 11:47
  • **Your calling session_start somewhere and output something before. That doesnt work** – Xatenev Sep 20 '16 at 11:47
  • please see the updated post – uneeb Sep 20 '16 at 11:50
  • @noman but this is creating an issue my headers redirection are not working – uneeb Sep 20 '16 at 11:52
  • Then you need to fix errors in your code as suggested here, http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php?answertab=active#tab-top – Noman Sep 20 '16 at 11:58
  • i did most of them not working for me anyways thanks for the help i thought there might be something silly i might be doing in my code – uneeb Sep 20 '16 at 11:59

1 Answers1

0

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.

pawan sen
  • 716
  • 5
  • 14
  • after creating a file name .user.ini where will the code come from it will be a blank file? – uneeb Sep 20 '16 at 13:03
  • if you not manage user.ini file second thing php.ini file in changes with using .htaccess or cpanel or php command output_buffering=On – pawan sen Sep 20 '16 at 13:31