Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    session_start();

    I'm having a problem with one of my files. I keep on getting the following error:

    Code:
    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/user/public_html/index.php:8) in /home/user/public_html/nmdeluxe/index.php on line 2
    The second line of the nmdeluxe/index.php file has the session_start(); code. There aren't any spaces before the <?php line. The file is in ANSI form. I'm also including this file in one of my other files using PHP includes.

    <? include("/home/user/public_html/nmdeluxe/index.php") ?>

    The public_html/index.php has that code in it. The nmdeluxe/index.php does include itself into the public_html/index.php file, but I that error message appears at the top of the page. How can I fix this?

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,024
    Thanks
    2
    Thanked 314 Times in 306 Posts
    From the error message - output started at ... public_html/index.php:8.

    Post your main index.php, something at or before line 8 is outputting content to the browser.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>title of website</title>
    
    
    <meta name="keywords" content="a, bunch, of, keywords">
    That goes up to line 8.

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,024
    Thanks
    2
    Thanked 314 Times in 306 Posts
    All of that is content that is output to the browser. You must execute a session_start() on any page that uses sessions prior to any content being output to the browser.
    Last edited by CFMaBiSmAd; 11-13-2007 at 05:15 PM. Reason: changed wording from "put" to "execute"
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    Regular Coder
    Join Date
    Jul 2007
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts
    So I need to add in a <?php session_start(); ?> at the beginning of my public_html/index.php file?

  • #6
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Correct.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •