0

我有一个带有会话的页面。当我从同一会话中的另一个页面访问该页面时,它会引发此错误:

警告:session_start() [function.session-start]:无法发送会话缓存限制器 - 标头已在 /home/cooperat/public_html/admin 中发送(输出开始于 /home/cooperat/public_html/admin/applyforloan.php:4) /applyforloan.php 在第 7 行

下面是页面的代码:

<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);

  $logoutGoTo = "appbye.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "101";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "apploginfail.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];



mysql_select_db($database_moneymanager, $moneymanager);
$query_members = "SELECT * FROM members";
$members = mysql_query($query_members, $moneymanager) or die(mysql_error());
$row_members = mysql_fetch_assoc($members);
$colname_members = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_members = $_SESSION['MM_Username'];
}
$username = $_SESSION['MM_Username'];
mysql_select_db($database_moneymanager, $moneymanager);
$query_members = sprintf("SELECT * FROM members WHERE username = %s", GetSQLValueString($colname_members, "text"));
$members = mysql_query($query_members, $moneymanager) or die(mysql_error());
$row_members = mysql_fetch_assoc($members);
$totalRows_members = mysql_num_rows($members);

mysql_select_db($database_moneymanager, $moneymanager);
$query_names = "SELECT First_name, last_name, memberid FROM members WHERE memberid != '2' AND username != '$username' ORDER BY memberid ASC";
$names = mysql_query($query_names, $moneymanager) or die(mysql_error());
$row_names = mysql_fetch_assoc($names);
$totalRows_names = mysql_num_rows($names);

$colname_loanername = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_loanername = $_SESSION['MM_Username'];
}
mysql_select_db($database_moneymanager, $moneymanager);
$query_loanername = sprintf("SELECT * FROM members WHERE username = %s", GetSQLValueString($colname_loanername, "text"));
$loanername = mysql_query($query_loanername, $moneymanager) or die(mysql_error());
$row_loanername = mysql_fetch_assoc($loanername);
$totalRows_loanername = mysql_num_rows($loanername);

mysql_select_db($database_moneymanager, $moneymanager);
$query_client = "SELECT * FROM customize";
$client = mysql_query($query_client, $moneymanager) or die(mysql_error());
$row_client = mysql_fetch_assoc($client);
$totalRows_client = mysql_num_rows($client);

$maxRows_contributions = 10;
$pageNum_contributions = 0;
if (isset($_GET['pageNum_contributions'])) {
  $pageNum_contributions = $_GET['pageNum_contributions'];
}
$startRow_contributions = $pageNum_contributions * $maxRows_contributions;
$name = $_POST ['membername'];
$maxRows_contributions = 10;
$pageNum_contributions = 0;
if (isset($_GET['pageNum_contributions'])) {
  $pageNum_contributions = $_GET['pageNum_contributions'];
}
$startRow_contributions = $pageNum_contributions * $maxRows_contributions;

$colname_contributions = "-1";
if (isset($_GET['year'])) {
  $colname_contributions = $_GET['year'];
}
$colname2_contributions = "-1";
if (isset($_GET['memberid'])) {
  $colname2_contributions = $_GET['memberid'];
}
$mid = $_POST['memberid'];
$year2 = $_POST['year2'];
$month2 = $_POST['month'];

$queryString_contributions = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_contributions") == false && 
        stristr($param, "totalRows_contributions") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_contributions = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_contributions = sprintf("&totalRows_contributions=%d%s", $totalRows_contributions, $queryString_contributions);
$row = $startRow_contributions + 1;
?>

我正在与 Dreamweaver 合作。请问你觉得哪里出了问题?

4

1 回答 1

0

似乎您已经在其他地方开始了一个会话,请确保session_start();在您的页面上调用一次,包括包含的 php 文件。

我假设 applyforloan.php 被包括在内。

于 2013-04-02T12:05:52.187 回答