53 users online (0 members and 53 guests)  


  Results 1 to 4 of 4

Related

  1. Replies: 8
  2. Replies: 0
  3. Error MySQL Error: 1064 - subqueries    Forum: PHP Forum
    Replies: 0
  4. please tell me where the error is    Forum: Javascript Forum
    Replies: 3
  1. #1
    bertugolu's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    15

    session_start() error

    I'm running a very simple scrpit but it is giving me an error


    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\neww\signin.php:5) in C:\wamp\www\neww\signin.php on line 7

    Source:
    PHP Code:
    <html>
    <head>
    <link href='styles.css'    rel='stylesheet' type='text/css'/>
    </head>
    <?php

    session_start
    ();
        
    if (empty(
    $_SESSION['count'])) {
    $_SESSION['count'] = 1;
    } else {
    $_SESSION['count']++;
    }
    echo 
    $_SESSION['count'];
    ?>
    when i use this script (removed the html part)
    PHP Code:
    <?php

    session_start
    ();
        
    if (empty(
    $_SESSION['count'])) {
    $_SESSION['count'] = 1;
    } else {
    $_SESSION['count']++;
    }
    echo 
    $_SESSION['count'];
    ?>
    it works :S:S

    help please, thanks a lot guys

  2. #2
    flann's Avatar
    New User

    Status
    Offline
    Join Date
    May 2007
    Posts
    18

    Re: session_start() error

    you can't start a session before you out put anything. Move the session_start() to the very top of the page, before any html and it should work.

  3. #3
    firmaterra's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    81

    Re: session_start() error

    Hi,

    What Flan Said! Or if its vital to output stuff (can't think when it is?!) put

    ob_start();
    at the top of the page

    and

    ob_flush();

    at the end of the page. This creates a buffer that catches all so that no output as such is sent from your script hence no 'headers already sent' errors. Also these errors can be caused by characters before/after your <?php ... /?> php tags so be sure to delete them (Even white space).

  4. #4
    bertugolu's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    15

    Re: session_start() error

    thanks guys xD



Tags for this Thread