Results 1 to 8 of 8

Thread: headers already sent error

  1. #1
    Join Date
    Mar 2011
    Posts
    2,025
    Thanks
    59
    Thanked 107 Times in 105 Posts
    Blog Entries
    4

    Default headers already sent error

    Warning: Cannot modify header information - headers already sent by (output started at /home1/keyboard/public_html/Canberra Amatuer Productions/database.php:6) in /home1/keyboard/public_html/Canberra Amatuer Productions/index.php on line 20

    PHP Code:
    <?php  
    require "database.php";
    $time time();  
    $date date("d/m/y");
    $greg time()+7200;
    $time2 date("h:i:s A"$greg);
    $hour time() + 3600

    if(isset(
    $_COOKIE['bobsmename'])){

    $cooksie $_COOKIE['bobsmename'];
    if (
    $cooksie != xgme1nlmn4_bobl00567dj){
    setcookie(bobsmenamexgme1nlmn4_bobl00567dj$hour);

    }else{
     

    $sql mysql_query ("INSERT INTO ip (id,time,time2,date,ip)
    VALUES ('0','"
    .$time."','".$time2."','".$date."','" $_SERVER['REMOTE_ADDR']."')"); 
    setcookie(bobsmenamexgme1nlmn4_bobl00567dj$hour); 
    }
    ?>

    <html>

    <head>


    <META name="description" content="Canberra Amatuer Productions is a place to find auditions for amateur theatre preformances or you can hire people, props and costumes.">


    </head>

    <body>



    <?php





     
    if(isset($_COOKIE['ID_my_site']))  
     {  
         
    $username $_COOKIE['ID_my_site'];  
         
    $pass $_COOKIE['Key_my_site'];  
              
    $check mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());  
         while(
    $info mysql_fetch_array$check ))       
             {  
      

             if (
    $pass != $info['password'])  
                 {           
                 }  
      
          
         else  
                 {  
                  
    $eval loggedin;     
    //        
                 
    }  
             }  
             }  
     else  
      

     {              
     
    $eval loggedout;  
     }  

    ?>

    <?php  
    $check 
    mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
    $info mysql_fetch_array$check );

    if ( 
    $eval == "loggedin" ){
    include(
    "link2.php");
    }else{
    include(
    "links.php");
    }
    ?>




    <table class="outter" width="900" align="center"> 

    <tr valign="top">
        
    <td class="menu">
        
    <table class="menu"><tr><td>    
    </td></tr></table>
        
    </td>
        
            
    <td width="500">
                
    <table class="main" cellpadding="8" width="100%" >
                
                
    <tr><td class="mainIn">
    <center>
     <p> 

    This site was created so that theatre groups, actors, backstage workers and anyone else interested in theatre in Canberra could get connected.
    Here, actors will be able to find acting opportunities.
    Theatre groups will be able to offer auditions, and also hire out props, sets and costumes from other productions. 
    They will also be able to find backstage help, giving backstage workers opportunities as well. </center>
        


    </td></tr>
                
    </table>
            
    </td>
    </body>


    </html>
    Any help?
    Last edited by keyboard; 09-22-2011 at 10:24 AM.

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    View your HTML source when you execute that page. Print your HTML source here. You code looks correct, but there must be some content sent before setcookie() is executed.
    - Josh

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Are there any other errors? These lines should produce errors or warnings if you have the error reporting on a high enough level. You need to use variables ($variable) or quoted strings ('string') rather than strings directly (string).

    if ($cooksie != xgme1nlmn4_bobl00567dj){
    setcookie(bobsmename, xgme1nlmn4_bobl00567dj, $hour);
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Mar 2011
    Posts
    2,025
    Thanks
    59
    Thanked 107 Times in 105 Posts
    Blog Entries
    4

    Default

    HTML Code:
    <br />
    <b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home1/keyboard/public_html/Canberra Amatuer Productions/database.php:6) in <b>/home1/keyboard/public_html/Canberra Amatuer Productions/index.php</b> on line <b>20</b><br />
    <html>
     
    <head>
     
     
    <META name="description" content="Canberra Amatuer Productions is a place to find auditions for amateur theatre preformances or you can hire people, props and costumes.">
     
     
    </head>
     
    <body>
     
     
     
     
    <link rel="stylesheet" type="text/css" href="test.css" />
    <title>Canberra Amatuer Productions</title>
     
     
    <body style="background-color:white">
     
     
     
     
    <img src="images/gold text edit.jpg" alt="Canberra Amatuer Productions" width="50" height="50"/> 
    <center><img src="images/Canberra.png" alt="Canberra Amatuer Productions" width="800" height="100"/> 
    </center>
     
     
    <center>
    <ul id="list-nav"> 
     
    <li><a href="index.php">Home</a></li>
    <li><a href="audition.php">Productions</a></li>
    <li><a href="products.php">Hire</a></li>
    <li><a href="databaseedit.php">Register</a></li>
    <li><a href="login.php">Login</a></li>
    <li><li><a href="contact.php">Contact Us</a></li></li>
    </ul>
    </center>
     
     
     
     
     
     
     
     
     
    <table class="outter" width="900" align="center"> 
     
    <tr valign="top">
    	
    <td class="menu">
    	
    <table class="menu"><tr><td>	
    </td></tr></table>
    	
    </td>
    	
    		
    <td width="500">
    			
    <table class="main" cellpadding="8" width="100%" >
    			
    			
    <tr><td class="mainIn">
    <center>
     <p> 
     
    This site was created so that theatre groups, actors, backstage workers and anyone else interested in theatre in Canberra could get connected.
    Here, actors will be able to find acting opportunities.
    Theatre groups will be able to offer auditions, and also hire out props, sets and costumes from other productions. 
    They will also be able to find backstage help, giving backstage workers opportunities as well. </center>
    	
     
     
    </td></tr>
    			
    </table>
    		
    </td>
     
     
     
     
     
     
     
     
     
     
    </body>
     
     
    </html>
    Yep, there's a <br /> tag. I don't know how to fix it. Any help would be great!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    There are two possibilities:
    1. There is a <br /> tag in database.php.
    or
    2. Are you including this page in another page? Is this the main page (the one you navigate to in your browser)? If there is another page, it might be in that page. This is unlikely because this page is named "index" so you are probably using it directly.

    If you can't figure it out, I suggest posting database.php here (with all usernames and passwords removed!).
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Mar 2007
    Location
    Dublin, Ireland
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Also, check your php.ini auto_prepend_file directive. It should be "off" or "none".

    I had this problem with one server configuration.

  7. #7
    Join Date
    Mar 2011
    Posts
    2,025
    Thanks
    59
    Thanked 107 Times in 105 Posts
    Blog Entries
    4

    Default

    This is database.php

    PHP Code:
    <?php
     mysql_connect
    ("localhost""****""****") or die(mysql_error()); 
     
    mysql_select_db("****") or die(mysql_error()); 
    ?>

  8. #8
    Join Date
    Mar 2011
    Posts
    2,025
    Thanks
    59
    Thanked 107 Times in 105 Posts
    Blog Entries
    4

    Default

    Now it works fine???
    Must have changed something.
    Thanks for everything guys.

    Keyboard1333

Bookmarks

Posting Permissions

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