【发布时间】:2015-04-01 18:01:36
【问题描述】:
几天来,我一直在尝试使用所有在线解决方案来解决此问题,但没有任何帮助。显然我错过了一个关键点,因为在 localhost 上它可以工作,但是当我把它放到网上时它就不行了。
错误: 警告:session_start():无法发送会话缓存限制器 - 第 3 行 /home/public_html/domain/index.php 中的标头已发送(输出开始于 /home/public_html/domain/index.php:1)
index.php
<?php
session_start();
include('functions/connect.php');
$page = htmlentities($_GET['page']);
include('functions/' . $page . '.func.php');
$pages = scandir('pages');
if (!empty($page) && in_array($_GET['page'] . '.php', $pages)) {
$content = 'pages/' . $_GET['page'] . '.php';
} else {
header('Location:index.php?page=register');
}
if (isset($_SESSION['uesername'])
) {
header("Location:index.php?page=member");
}
?>
<!DOCTYPE html>
<html>
<head>
<link href="css/mojcss.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id='content'>
<?php
include($content);
?>
</div>
</body>
</html>
connect.php
<?php
$link = @mysql_connect('localhost','myusername','mypass'); //or die('error');
if(!$link)
{
$message="<strong><font color='red'>Error, try later.</font></strong><br /><br />";
die($message.mysql_error());
}
$db = mysql_select_db('mydb'); //or die('unable to connect');
if(!$db)
{
$message="<strong><font color='red'>Error, try later.</font></strong><br /><br />";
die($message.mysql_error());
}
?>
【问题讨论】:
-
不幸的是,这没有帮助:/
-
从您包含的 php 文件中删除
?>。可能会有一些结束的新行将作为响应正文内容发送到浏览器