Help With A Script

Discussion in 'PHP' started by ZaxiHosting, Sep 4, 2007.

  1. #1
    Hello,
    Recently I buy a website.
    I try to install a clean setup(the same results I had with move too.) But I receive one big error.
    When I enter codes,above <?php in the .index.php file,the file "crash" and returns:
    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/*/public_html/my-sl.net/index.php:4) in /home/*/public_html/my-sl.net/include/session.class.inc.php on line 68

    In line4 in index,it is <?php
    And in line 68 it is session_start();

    What Can I Do?
    Thank you
     
    ZaxiHosting, Sep 4, 2007 IP
  2. NickD

    NickD Well-Known Member

    Messages:
    262
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #2
    You cannot start a session after any output has been products, echo, printed ect. You can use output buffering to get around this..

    php.net/ob_start
    php.net/ob_end_flush
     
    NickD, Sep 4, 2007 IP
  3. ZaxiHosting

    ZaxiHosting Well-Known Member

    Messages:
    1,996
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    130
    #3
    So what can I Do?
    I want some ads and title,keywords and description to be before php code start.
    Regards
     
    ZaxiHosting, Sep 4, 2007 IP
  4. NickD

    NickD Well-Known Member

    Messages:
    262
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Make this the very first line of your file:

    <?php
    ob_start();
    ?>

    Put this at the end of your file:

    <?php
    ob_end_flush();
    ?>
     
    NickD, Sep 4, 2007 IP
  5. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #5
    A better solution is that you find the "start_session();" and add your code after it.
    Or you could simply show us your source code.
     
    nabil_kadimi, Sep 4, 2007 IP
  6. ZaxiHosting

    ZaxiHosting Well-Known Member

    Messages:
    1,996
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    130
    #6
    @nabil_kadimi
    I have tried this before but nothing.
    It solved with Nickd solution:)
    Thank you both!
     
    ZaxiHosting, Sep 4, 2007 IP