...

View Full Version : Warning: session_start() [function.session-start]:



bibi822
09-20-2009, 08:37 AM
I'm getting this error. This is for my header.php

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/bibico5/public_html/mm2213/loginfail.php:107) in /home/bibico5/public_html/mm2213/includes/header.inc.php on line 1



<?php require_once('../Connections/connAdmin.php'); ?>
<?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;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "../membersonly.php";
$MM_redirectLoginFailed = "../loginfail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connAdmin, $connAdmin);

$LoginRS__query=sprintf("SELECT username, username FROM users WHERE username=%s AND username=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $connAdmin) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}

if (isset($_POST['pwd'])) { $_POST['pwd'] = sha1($_POST['pwd']); }
?>

FWDrew
09-20-2009, 09:05 AM
Remove:


if (!isset($_SESSION)) {
session_start();
}

And start your sessions with
session_start(); before doing anything else, I'm assuming in header.inc.php.

bibi822
09-20-2009, 09:13 AM
So i put this in the very beginning of my header.inc.php?

<?php session_start(); ?>

FWDrew
09-20-2009, 09:17 AM
So i put this in the very beginning of my header.inc.php?

<?php session_start(); ?>
Yes, call session_start before any other code or other file(s).

Edit - See the answer to the FAQ here (http://codingforums.com/showthread.php?p=300877#post300877), this is a common issue.

bibi822
09-20-2009, 09:47 AM
it doesn't seem to work..
it's wierd..
after deleted

if (!isset($_SESSION)) {
session_start();
}

then put session_start in the first line

<?php session_start(); ?>

and then this pops up
"The Server Behavior panel cannot determine whether "log in user" or "log in user" is applied to your page. Please select edit server behavior and change one of the two behaviors to ensure that each is uniquely identifiable."

and then 2 "log in user" appears on the behavior tab...


This is the whole code on my header.inc.php right now


<?php session_start(); ?>
<?php require_once('../Connections/connAdmin.php'); ?>
<?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;
}
}
?>
<?php
// *** Validate request to login to this site.
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "../membersonly.php";
$MM_redirectLoginFailed = "../loginfail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connAdmin, $connAdmin);

$LoginRS__query=sprintf("SELECT username, username FROM users WHERE username=%s AND username=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $connAdmin) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}

if (isset($_POST['pwd'])) { $_POST['pwd'] = sha1($_POST['pwd']); }
?>
<div id="header">
<div id="top"></div>
<div id="login">
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
Username:
<label>
<input name="username" type="text" id="username" size="15" />
</label>
<br />
Password:
<label>
<input name="password" type="text" id="password" size="15" />
</label>
<br />
Register Agent
<label>
<input name="login" type="submit" class="button" value="login" />
</label>
</form>
</div>
<div id="logo">
<img src="images/logo1.jpg" width="401" height="67" />

<br />
</div>
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="#" id="current">ABOUT</a></li>
<li><a href="#">NEWS</a></li>
<li><a href="#">BUYER</a></li>
<li><a href="#">SELLER</a></li>
<li><a href="#">LISTING</a></li>
<li><a href="#">CONTACT</a></li>
</ul>
</div>
<div id="search"><div id="sb2">
<div id="sb_head">Find a Home</div>
<div id="find_t">
<div id="left_f">
<p class="contr">Cities:
<select class="countr">
<option value="Pasadena">Pasadena</option>
<option value="Arcadia">Arcadia</option>
<option value="San Marino">San Marino</option>
<option value="Monrovia">Monrovia</option>
<option value="San Gabriel">San Gabriel</option>
</select></p>
<p class="contr">Price:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;To:<br />
<select name="select" class="countr1">
<option>max</option>
<option>max</option>
</select>
&nbsp;
<select name="select2" class="countr1">
<option>min</option>
<option>min</option>
</select>
</p>
<p class="contr">
<input name="Search" type="button" value="Search" />
</p>

</div>
<div id="right_f">
<p class="bed">Beds:
<select class="beds">
<option>0</option>
<option>1</option>
</select></p>
<p class="bed">Baths:
<select class="beds">
<option>0</option>
<option>1</option>
</select></p>
</div>
</div>
</div></div>
<div id="house">
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="514" height="224">
<param name="movie" value="flash/house.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you donít want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="flash/house.swf" width="514" height="224">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum