Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Douglas Fernandess

[Resolvido] Erro Warning: session_start() [function.session-star

Recommended Posts

Tenho o seguinte código acima de tudo

 

 

<?php require_once('Connections/painel_config.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

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

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

if (isset($_POST['usuario'])) {
 $loginUsername=$_POST['usuario'];
 $password=md5($_POST['senha']);
 $MM_fldUserAuthorization = "usuarioNivel";
 $MM_redirectLoginSuccess = "admin/painel.php";
 $MM_redirectLoginFailed = "admin/erro.php";
 $MM_redirecttoReferrer = false;
 mysql_select_db($database_painel_config, $painel_config);

 $LoginRS__query=sprintf("SELECT email, senha, usuarioNivel FROM up_clientes WHERE email=%s AND senha=%s",
 GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

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

   $loginStrGroup  = mysql_result($LoginRS,0,'usuarioNivel');

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
   //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 );
 }
}
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

A diretriz session_start() deve ser a primeira linha em seu arquivo, para evitar problemas como enviar qualquer resultado para a página antes da chamada.

 

Verifique se o arquivo que você está incluindo no início da página está enviando algum dado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

bom coloquei a session na primeira linha mais continua dando o mesmo erro, como eu faria para ver se esta enviando algum dado?

 

 

<?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['usuario'])) {
 $loginUsername=$_POST['usuario'];
 $password=md5($_POST['senha']);
 $MM_fldUserAuthorization = "usuarioNivel";
 $MM_redirectLoginSuccess = "admin/painel.php";
 $MM_redirectLoginFailed = "admin/erro.php";
 $MM_redirecttoReferrer = false;
 mysql_select_db($database_painel_config, $painel_config);

 $LoginRS__query=sprintf("SELECT email, senha, usuarioNivel FROM up_clientes WHERE email=%s AND senha=%s",
 GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

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

   $loginStrGroup  = mysql_result($LoginRS,0,'usuarioNivel');

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
   //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 );
 }
}
?>
<?php require_once('Connections/painel_config.php'); ?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

O que o marcelo.lipienski falou está correto e se qualquer espaço em branco tiver sido deixado para traz, seja em outro arquivo ou no atual, já da mer**.

Talvez de pra resolver assim:

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

Compartilhar este post


Link para o post
Compartilhar em outros sites

Usei esse comando

 

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

 

 

e não deu certo também.

 

A página está em PHP, o script eu uso na minha máquina local, e funciona certinho, e em outra empresa de hospedagem também, daí upei para o FTP do meu cliente e deu esse erro aí :S

 

Bom sobre o espaço em branco seria só na mesma função? ou em qualquer outro lugar?

Compartilhar este post


Link para o post
Compartilhar em outros sites

<html>
 <head>
   <title>Blabla</title>
 </head>
 <body>
 <?php
   session_start();
 ?>
 </body>
</html>

 

isso vai dar o erro que está acontecendo com você, porque o servidor já enviou parte do código HTML antes de processar o PHP.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Estaria dando esse erro no meu cabecario do site, se ficar melhor para entende vou posta ele inteiro aqui

 

 

<?php require_once('Connections/painel_config.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['usuario'])) {
 $loginUsername=$_POST['usuario'];
 $password=md5($_POST['senha']);
 $MM_fldUserAuthorization = "usuarioNivel";
 $MM_redirectLoginSuccess = "admin/painel.php";
 $MM_redirectLoginFailed = "admin/erro.php";
 $MM_redirecttoReferrer = false;
 mysql_select_db($database_painel_config, $painel_config);

 $LoginRS__query=sprintf("SELECT email, senha, usuarioNivel FROM up_clientes WHERE email=%s AND senha=%s",
 GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

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

   $loginStrGroup  = mysql_result($LoginRS,0,'usuarioNivel');

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
   //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 );
 }
}
?>
<!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>
<?php include"scripts/limita_palavras.php"; ?>
<?php include"scripts.php";?>
<?php include"Connections/config.php";?>
<?php include"js/scripts.php";?>
<?php include"funcoes.php";?>
<script type="text/javascript" src="scripts/m_func.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Guia Mart | A Um Clique do Que Você Procura </title>
<meta name="description" content=" "/> 
<meta name="keywords" content="guia mart, guia, mart, clique, procura, melhor" />
<meta name="rating" content="Geral" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="expires" content="never" />
<meta name="language" content="portuguese" />
<meta name="distribution" content="Global" />
<meta name="robots" content="all" />
<meta name="revisit-after" content="1 day" />
<link href="imgs/favicon.ico" rel='shortcut icon'/> 
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<script type="text/javascript">
//<!--
$(document).ready(function() {$(".box-curtir-flutuante").hover(function() {$(this).stop().animate({right: "0"}, "medium");}, function() {$(this).stop().animate({right: "-250"}, "medium");}, 500);});
//-->
</script>
<style type="text/css">
.box-curtir-flutuante{background: url("imgs/f.png") no-repeat scroll left center transparent !important;display: block;float: right;height: 270px;padding: 0 0 0 46px;width: 245px;z-index: 99999;position:fixed;right:-250px;top:20%; }
.box-curtir-flutuante div{border:none;position:relative;display:block;}
.box-curtir-flutuante span{bottom: 12px;font: 8px "lucida grande",tahoma,verdana,arial,sans-serif;position: absolute;right: 6px;text-align: right;z-index: 99999;}
.box-curtir-flutuante span a{color: #808080;text-decoration:none;}
.box-curtir-flutuante span a:hover{text-decoration:underline;}
</style><div class="box-curtir-flutuante" style=""><div>
<iframe src="http://www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/pages/Guia-Mart/209206569154958&width=245&colorscheme=light&show_faces=true&connections=9&stream=false&header=false&height=270" scrolling="no" frameborder="0" scrolling="no" style="border: medium none; overflow: hidden; height: 270px; moz-border-radius: 10px; /* Para Firefox */
   webkit-border-radius: 10px; /*Para Safari e Chrome */
   border-radius: 10px; /* Para Opera 10.5+*/ width: 245px;background:#fff;"></iframe></div></div>


 <div id="header">

<div id="cabecario">


     <a href="index.php"><embed src="imgs/logo.swf" width="1025" height="150" wmode="transparent"></embed></a>

	</div><!-- CABECARIO-->


  <div id="menu">

       <a href="index.php" title="Início">Início</a>  
	<a href="index.php?pg=anunciar" title="Anunciar">Anunciar</a>  
       <a href="index.php?pg=anuncie" title="Cadastrar">Cadastar</a>  
       <a href="index.php?pg=escritorio" title="Escritório">Escritório</a>  
       <a href="index.php?pg=contato" title="Contato">Contato</a>  
       <a href="index.php?pg=mapa" title="Mapa">Mapa</a>  

</div> <!--FIM MENU-->




 <div id="menu_search">

       <form name="search" action="index.php?pg=search" method="post">

         <input  type="text" name="pesquisa" />

       <input type="submit" name="Buscar"   title="Buscar" value="" class="search_btn" />

       </form>      

     </div> <!--Search-->


  </div><!--fecha o header-->


  <div id="layout">


  <div id="sidebar_esq">

 <?php include"sidebars/sidebar_esq.php";?>

       </div><!--FIM SIDEBAR ESQ-->

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.