2013-06-26 137 views
1

好傢伙對不起,我就到我的昨天愚蠢的問題,質疑其沒有解決會話工作在本地主機正常,但不能上網(交友)

但即使你給了,但仍然沒有工作的建議。我刪除了所有的空格,但

仍然顯示我的問題。它在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> 
+0

你在'<?php'之前有一些字符在你的代碼中......也許在一個包含的文件中。剝去代碼,直到錯誤消失。它只在你的本地主機上工作,因爲你有輸出緩衝。問題是你的代碼,而不是你的主機。 – Brad

+0

把'exit();'放在'header'後面。 –

+0

這是做什麼@YogeshSuthar – DevZer0

回答

0

確保在session_start()之前沒有輸出空格或文本。

+0

在session_start()之前沒有多餘的空格。 –

+0

它也可以在<?php' – dtbarne

+0

之前在<?php –

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

編輯:也是任何空格,HTML代碼之前<?php?>後的PHP標籤可能導致此錯誤。有在SO Headers already sent by PHP

+0

之前沒有空格正如您給出的指示,我確實喜歡那樣,但仍然存在問題。 –

+0

你把它放在包含的第一個文件中嗎?當它重定向到新的時候,你也需要在那裏添加它。 –

+0

我無法粘貼整個代碼在這裏以任何方式粘貼所有3頁代碼PLZ –

0

在這裏這個問題的一個偉大的答案對我來說,解決方案是<?php session_start()您已經刪除之前刪除的任何代碼。至少這是你的想法。在我的index.php中添加了一些代碼後,我從頭文件中刪除了session_start,並將其作爲我的index.php或任何其他main.php文件中的第一個代碼。

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