在线服务器上有问题,但在本地服务器上有效

时间:2019-01-18 14:06:20

标签: javascript php server

我在这里呆了一天。我尝试了所有可能的解决方案,但无法解决问题。 我收到的错误是:

  

“警告:session_start():无法发送会话cookie-标头   已发送者(输出始于   /storage/ssd2/309/8480309/public_html/index.php:22)在   /storage/ssd2/309/8480309/public_html/index.php,第24行警告:   session_start():无法发送会话缓存限制器-标头已经   已发送(输出始于   /storage/ssd2/309/8480309/public_html/index.php:22)在   /storage/ssd2/309/8480309/public_html/index.php,第24行“

我已参考以下链接。     How to fix "Headers already sent" error in PHP

<!-- Custom styles for this template -->
<link href="carousel.css" rel="stylesheet">
<?php     -----------LINE 22
ob_start();
session_start();  -----------------LINE 24

    $con=mysql_connect('localhost','**','**');
    if(!$con)
    {
        die('could not connect: '.mysql_error());
    }
    mysql_select_db("id8480309_litezomato");

//      Setting Function of Search button of Location Dropdown
    if(isset($_POST['search']))
    {
        $loc=$_POST['loc'];
        $_SESSION['loc']=$loc;
        header("location:list.php");

    }

//      Sign Up Form
    if(isset($_POST['signup_submit']))
    { 
        if($_SERVER["REQUEST_METHOD"]=="POST")
        {
            $u_name=$_POST['signup_name'];
            $u_id=$_POST['signup_email'];

            $sign_up="insert into user values('$u_name','$u_id')";

            $res=mysql_query($sign_up,$con);
            if(!$res)
            {
                $message1 = "User Already Exist";
                echo "<script type='text/javascript'>alert('$message1'); 
   </script>";
            }
            else
            {
                $message = "User Subscribed Successfully";
                echo "<script type='text/javascript'>alert('$message') 
</script>";
}
}
}
ob_end_flush();        
?>
</head>

我正在尝试将其托管在000webhost上。此警告正在显示。

0 个答案:

没有答案