Log in

View Full Version : Resolved headers already sent error



keyboard
09-22-2011, 02:53 AM
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
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(bobsmename, xgme1nlmn4_bobl00567dj, $hour);
}
}else{


$sql = mysql_query ("INSERT INTO ip (id,time,time2,date,ip)
VALUES ('0','".$time."','".$time2."','".$date."','" . $_SERVER['REMOTE_ADDR']."')");
setcookie(bobsmename, xgme1nlmn4_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?

JShor
09-22-2011, 03:27 AM
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.

djr33
09-22-2011, 03:33 AM
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);

keyboard
09-22-2011, 03:59 AM
<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!

djr33
09-22-2011, 04:05 AM
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!).

Butterfly
09-22-2011, 04:57 AM
Also, check your php.ini auto_prepend_file directive. It should be "off" or "none".

I had this problem with one server configuration.

keyboard
09-22-2011, 06:57 AM
This is database.php



<?php
mysql_connect("localhost", "****", "****") or die(mysql_error());
mysql_select_db("****") or die(mysql_error());
?>

keyboard
09-22-2011, 10:24 AM
Now it works fine???
Must have changed something.
Thanks for everything guys.

Keyboard1333