Web Analytics Made Easy -
StatCounter Warning: session_start(): Cannot send session cache limiter - headers already sent... - CodingForum

Announcement

Collapse
No announcement yet.

Warning: session_start(): Cannot send session cache limiter - headers already sent...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Warning: session_start(): Cannot send session cache limiter - headers already sent...

    Hi!

    I have googled a lot about this problem now and tried to fix problem with my code.
    Still there is an error:
    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /customers/9/9/3/mediakusten.se/httpd.www/planering/login.php:1) in /customers/....../login.php on line 2  Warning: Cannot modify header information - headers already sent by (output started at /customers/..../login.php:1) in /customers/..../login.php on line 19

    I have masked the url.
    This is just for me to test a small program with database. Works fine on localhost.
    Here comes the code:

    <?php
    session_start();
    @ob_start();


    if(isset($_POST['submit'])) {
    $userN=$_POST['username'];
    $passW=$_POST['password'];
    include('connect.php');
    $userid=mysqli_real_escape_string($conn,$userN);
    $pass=mysqli_real_escape_string($conn,$passW);

    $query = "SELECT * FROM user WHERE username='$userid' AND password='$pass'";
    $result = mysqli_query($conn, $query);
    $row = mysqli_fetch_array($result);

    if($row){
    $_SESSION['userN']=$userid;
    header('location: backend/backend.php');
    exit;
    }
    else{
    echo "Wrong username or password!<br>";
    echo "<a href='index.php'>Try again</a>";
    }
    }?>

    Hope you have an idea!
    Thanks for helping!
    //P

  • #2
    Noone?

    Comment


    • #3
      What code is inside connect.php?

      I suspect you have whitespace somewhere before the php opening tags - a space character for example.
      "Tango says double quotes with a single ( ' ) quote in the middle"
      '$Name says single quotes with a double ( " ) quote in the middle'
      "Tango says double quotes ( \" ) must escape a double quote"
      '$Name single quotes ( \' ) must escape a single quote'

      Comment


      • #4
        Your googling should have solved this. This common problem has been posted and answered several 100 thousand times on the web.

        You have output on line 1 of your file. Since there's no code after the php tag that's outputting anything on line one, that must mean there's something before the php tag. If there are no characters in your file before the php tag on line one, that means that your file has been saved by your editor with the BOM (Byte Order Mark) characters. Save the file without the BOM.

        Also, remove the ob_start() statement and NEVER use code that has an @ error suppressor in it.
        Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

        Comment

        Working...
        X