会话正在Localhost正常但不在线(Cpanel)

时间:2013-06-26 04:03:53

标签: php mysql

大家好,很抱歉我的昨天问题没有解决我的愚蠢问题

即使你给出的建议,但仍然没有工作。我删除了所有空格,但

仍然为我显示问题。它在localhost中工作得很好,但在CPANEL中却没有。

以下是错误:

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" );
    }
    ?>

如果条件为真,则会通过名称REPLists.php将其重定向到页面

这是页面。

<?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>

3 个答案:

答案 0 :(得分:1)

您需要将ob_start()放在脚本的开头,然后ob_flush()放在最后。这样做是因为您的标头已经发送,session_start会抛出错误,因为它试图发送另一个标头参数。

<?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();
?>

编辑:也可以在<?php之前的任何空格,html代码或?>之后的php标记导致此错误。 SO Headers already sent by PHP

在这个问题上有一个很好的答案

答案 1 :(得分:0)

确保在session_start()之前没有输出空格或文字。

答案 2 :(得分:0)

对我来说,解决方案是删除您已删除的<?php session_start()之前的所有代码。至少那是你的想法。在一些代码之后,我的头文件包含在我的index.php中。我从header中删除了session_start并将其作为index.php中的第一个代码或任何其他main.php文件。

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