1

Hello guys Sorry for my stupid question regarding to my yesterday question its not solved

yet even the advice you have given but still not working. i have removed all of spaces but

still showing the problem for me. it's working perfect in localhost but not in CPANEL.

Here is the errors which give:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/scalepro/public_html/Admin Panel/Remote Employee/main.php:1) in /home/scalepro/public_html/Admin Panel/Remote Employee/main.php on line 1

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/scalepro/public_html/Admin Panel/Remote Employee/main.php:1) in /home/scalepro/public_html/Admin Panel/Remote Employee/main.php on line 1

    Warning: Cannot modify header information - headers already sent by (output started at /home/scalepro/public_html/Admin Panel/Remote Employee/main.php:1) in /home/scalepro/public_html/Admin Panel/Remote Employee/main.php on line 13

    Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0

ANY ONE PLEASE ???

Here is my code:

    <?php session_start(); 
    require_once('../../Admin Panel/db.php');
    if(isset($_POST['email']) && !empty($_POST['email']) && isset($_POST['password']) && !empty($_POST['password']))
    {
     $email = $_POST['email'];
     $password = $_POST['password'];
     $query="SELECT RemoteEmployeeFullName, RemoteEmployeeEmail, RemoteEmployeePassword FROM remoteemployees WHERE RemoteEmployeeEmail='".$email."' AND RemoteEmployeePassword='".$password."'";
     $queryrun=$connection->query($query);
     if($queryrun->num_rows > 0)
     {
         $_SESSION['email']=$RemoteEmployeeFullName;     
         header("Location: /home/scalepro/public_html/Admin Panel/Remote Employee/REPLists.php");
     }
     else
     {
        echo 'Email: <b>'.$email. '</b> or Password <b>'. $password.'</b> Is Not Typed Correctly Try Again Please!.';
        header( "refresh:5;url= /home/scalepro/public_html/spd/myaccount.php" );
     }

    }
    else
    {
        header( "refresh:5;url= /home/scalepro/public_html/spd/myaccount.php" );
    }
    ?>

if the condition gets true this will be redirected to a page by the name of REPLists.php

here is the page.

<?php session_start();
require_once('../../Admin Panel/db.php');
?>
<html>
<head>
<style>
.wrapper
{
  width:1250px;
  height:auto;
  border:solid 1px #000;
  margin:0 auto;
  padding:5px;
  border-radius:5px;
  -webkit-border-radius:5px;
  -moz-border-radius:5px;
  -ms-border-radius:5px;
}
.wrapper .header
{
  width:1250px;
  height:20px;
  border-bottom:solid 1px #f0eeee;
  margin:auto 0;
  margin-bottom:12px;
}
.wrapper .header div
{
text-decoration:none;
color:#F60;
}
.wrapper .header div a
{
text-decoration:none;
color:#F60;
}
.wrapper .Labelcon
{
  width:1250px;
  height:29px;
  border-bottom:solid 1px #ccc;
}

.wrapper .Labelcon .Label
{
  width:125px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font:Verdana, Geneva, sans-serif;
  font-size:14.3px;
  font-weight:bold;

}
.wrapper .Valuecon
{
  width:1250px;
  height:29px;
  border-bottom:solid 1px #ccc;
  color:#F60;
  text-decoration:none;
}
.wrapper .Valuecon .Value
{
  width:125px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font-size:14px;
}
</style>
</head>
<body>
<div class="wrapper">

<div class="header">
<div style="float:left;"><font color="#000000">Email: 
</font>
<?php 
if(isset($_SESSION['email']))
{
echo $_SESSION['email'];
}
?>

</div>
<div style="float:right;">  <a href="#">My Profile</a> | <a href="logout.php">Logout</a></div>
</div>


<div class="Labelcon">
  <div class="Label">Property ID</div>
  <div class="Label">Property Type</div>
  <div class="Label">Property Deal Type</div>
  <div class="Label">Property Owner</div>
  <div class="Label">Proposted Price</div>
</div>
<?php
if(!isset($_SESSION['email']))
{
  header('Location:../../spd/myaccount.php');
}
else
{
  $query = "SELECT 
   properties.PropertyID,
   properties.PropertyType,
   properties.PropertyDealType,
   properties.Status,
   properties.PropostedPrice,

   remoteemployees.RemoteEmployeeFullName,

   propertyowners.PropertyOwnerName,
   propertydealers.PropertyDealerName

   FROM remoteemployees,
        propertyowners,
        propertydealers,
        properties

   WHERE 

   properties.PropertyOwnerID=propertyowners.PropertyOwnerID

   AND properties.PropertyDealerID=propertydealers.PropertyDealerID

   AND remoteemployees.RemoteEmployeeID=properties.RemoteEmployeeID



   ORDER BY properties.PropertyID
   ";

  $query_run = $connection->query($query);
  if( $connection->error ) exit( $connection->error );
  while($row=$query_run->fetch_assoc()) 
  {

?>
<div class="Valuecon">
  <div class="Value"><?php echo $row['PropertyID'] ?></div>
  <div class="Value"><?php echo $row['PropertyType'] ?></div>
  <div class="Value"><?php echo $row['PropertyDealType']?></div>
  <div class="Value"><?php echo $row['PropertyOwnerName'] ?></div>
  <div class="Value"><?php echo $row['PropostedPrice'];?></div>
</div>

<?php } }?>
</div>
</body>
</html>
nando pandi
  • 63
  • 2
  • 7

3 Answers3

1

You need to put ob_start() at the beginning of your script and ob_flush() at the end. its doing this because your headers are already sent and session_start will throw an error because its attempting to send another header parameter.

<?php 
  // ob_start holds data in the script, 
  // instead of sending data in pieces
  ob_start();

  // your php code

  // ob_flush sends all the data to the browser
  ob_flush();
?>

Edit: also any whitespace, html code before <?php or after ?> the php tags can cause this error. there is a great answer on this question here at SO Headers already sent by PHP

Community
  • 1
  • 1
Jay Harris
  • 4,201
  • 17
  • 21
  • As you have given instruction i did like that but still problem exist. – nando pandi Jun 26 '13 at 04:26
  • did you put it in the first file that is included ? and when it redirects to a new one, you'll need to add it there too. – Jay Harris Jun 26 '13 at 04:32
  • i cant paste the whole code in here any way to paste all 3 pages code plz – nando pandi Jun 26 '13 at 04:44
  • you have three similar errors `headers already sent` and the fourth i never seen before. the three are referring to header calls in your if else statements `header( "refresh:5;url= /home/scalepro/public_html/spd/myaccount.php" );` putting all header and session calls in between `ob_start();` and `ob_flush();` should solve your problem. – Jay Harris Jun 26 '13 at 04:53
  • you mean there is a prob with my if else statement, also i have used exit(); after each header – nando pandi Jun 26 '13 at 04:58
  • no its not the if else i was just telling you, that you can't modify the header without buffering your script. is there any whitespace before your – Jay Harris Jun 26 '13 at 05:08
  • any space for posting my codes cause there is no extra spaces in header and start of my php tag. – nando pandi Jun 26 '13 at 05:21
0

Make sure there is no whitespace or text outputted before session_start().

dtbarne
  • 8,110
  • 5
  • 43
  • 49
0

For me the solution was to remove any code before <?php session_start() which you've already removed. At least that's what you think. I had my header included in my index.php after some code. I removed session_start from header and put this as the very first code in my index.php or any other main.php file.

<?php ob_start();if(!isset(session)){session_start();}
else echo "Session Started already, bro!?>
innocent rock
  • 129
  • 10