douzhuijing4911 2015-12-10 19:58
浏览 25
已采纳

已发送的标头,找不到错误,日志说它是HTML [重复]

This question already has an answer here:

Yes, this question have a lot of duplicates one. But, in my code I really can't figure out where the problem is. I've done some research in another answers before I ask here, but, none is the same. Tried to look at spaces after everything. Removed that spaces, nothing work at all. The error:

<b>Warning</b>:  session_start(): Cannot send session cookie - headers already sent by (output started at /home/monyf176/public_html/borasair.com/dev/header.php:82) in <b>/home/monyf176/public_html/borasair.com/dev/adminpage.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>:  session_start(): Cannot send session cache limiter - headers already sent (output started at /home/monyf176/public_html/borasair.com/dev/header.php:82) in <b>/home/monyf176/public_html/borasair.com/dev/adminpage.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/monyf176/public_html/borasair.com/dev/header.php:82) in <b>/home/monyf176/public_html/borasair.com/dev/adminpage.php</b> on line <b>7</b><br />

The line near 82 on header.php:

                </li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav> -> thats one is the 82 (HTML!!!)

Start of adminpage.php:

<?php
include('header.php');
include('functions.php');
session_start();

if(!isset($_SESSION['user_email'])) { //Check if isn't logged in
    header('Location: lib/logout.php');
} else { ?> <!-- If the user are logged in display the page -->

I can't find what is wrong. I know that there are a lot of duplicate cases. But I need help with this project.

</div>
  • 写回答

1条回答 默认 最新

  • douzhang3822 2015-12-10 20:00
    关注

    If there is anything at the top before the <?php ?> tags, it will be considered output, thats why you get the headers are already sent. so make sure the session_start() is at the top of the page, you can make its own php tags alone and then continue with others. In simple terms, Just put session_start() at the top before you include your headers.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并