AdRock Posted March 30, 2008 Share Posted March 30, 2008 I am trying to help a mate who is learning php. He says he is getting headers already sent but his php is at the top of the page before any html is output. It works fine on my machine and he uses the exact same code and gets errors Any ideas why? Link to comment https://forums.phpfreaks.com/topic/98705-question-on-headers-already-sent/ Share on other sites More sharing options...
marklarah Posted March 30, 2008 Share Posted March 30, 2008 post the code. Link to comment https://forums.phpfreaks.com/topic/98705-question-on-headers-already-sent/#findComment-505139 Share on other sites More sharing options...
AdRock Posted March 30, 2008 Author Share Posted March 30, 2008 This isn't my code but i still don't know why it saying this init.php <?php session_start(); $host="localhost"; $user="root"; $password="201271"; $database="mycarshare"; mysql_connect($host,$user,$password); @mysql_select_db($database) or die( "Unable to select database"); ?> login.php <?php include_once("init.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My Car Share - Home Page</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="default.css" type="text/css" /> <style type="text/css"> <!-- .style1 {color: #FFFFFF} a:hover { color: #99CCFF; text-decoration: none; } .style2 { font-family: Verdana, Arial, Helvetica, sans-serif; color: #FFCC33; } .style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; } a:link { text-decoration: none; } a:visited { text-decoration: none; } a:active { text-decoration: none; } --> </style> </head> <body bgcolor="#ff9933"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#FF9900"> <td width="15" nowrap="nowrap" bgcolor="#ff9933" ></td> <td height="60" colspan="3" nowrap="nowrap" bgcolor="#ff9933" class="logo"><img src="header.png" width="680" height="80" /><br /></td> <td width="40" bgcolor="#ff9933"/> <td width="100%" bgcolor="#ff9933"/> </tr> <tr bgcolor="#003399"> <td width="15" nowrap="nowrap" bgcolor="#ff9933"/> <td height="36" colspan="3" nowrap="nowrap" bgcolor="#ff9933" class="navText" id="navigation"><a href="index.html">INDEX</a> <a href="login.html">LOGIN</a> <a href="register.html">REGISTER</a> <a href="search.html">SEARCH</a> <a href="contactus.html">CONTACT US</a> </td> <td width="40" bgcolor="#ff9933"/> <td width="100%" bgcolor="#ff9933"/> </tr> <tr bgcolor="#ffffff"> <td colspan="6"></td> </tr> <tr bgcolor="#ffffff"> <td width="230" colspan="2" valign="top" bgcolor="#ffffff"><table border="0" cellspacing="0" cellpadding="0" width="230"> <tr> <td width="15"> </td> <td width="200" class="smallText" id="padding"><form id="login" name="login" method="post" action="checklogin.php"> <p class="style2">Login</p> <p> <label><span class="style4">Email</span><br /> <input type="text" id="myemail" name="myemail" /> </label> </p> <p> <label><span class="style4">Password</span> <input type="password" id="mypassword" name="mypassword" /> </label> </p> <p> <label> <input type="submit" name="submit" id="submit" value="Login" /> </label> </p> </form> <br /> </td> <td width="15"> </td> </tr> </table> </td> <td width="50" valign="top"></td> <td width="440" valign="top"><br /> <br /> <table border="0" cellspacing="0" cellpadding="0" width="440"> <tr> <td class="pageHeader">Login</td> </tr> <tr> <td class="bodyText"><p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. </p> <p> </p> <br /> </td> </tr> </table> </td> <td width="40"> </td> <td width="100%"> </td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"></td> </tr> <tr> <td colspan="6"/> </tr> <tr> <td width="15"/> <td width="215"/> <td width="50"/> <td width="440"/> <td width="40"/> <td width="100%"/> </tr> </table> <address>© <a href="mailto:[email protected]" class="style1">My Car Share</a> </address> </body> </html> There is no whitespace cos we have checked Link to comment https://forums.phpfreaks.com/topic/98705-question-on-headers-already-sent/#findComment-505141 Share on other sites More sharing options...
marklarah Posted March 30, 2008 Share Posted March 30, 2008 May help you: http://www.expertsrt.com/tutorials/Matt/HTTP_headers.html also, try removing the space before the <?php tag and the sesssion start. Also, make sure no redirects are being sent in the middle of the page. Link to comment https://forums.phpfreaks.com/topic/98705-question-on-headers-already-sent/#findComment-505147 Share on other sites More sharing options...
AdRock Posted March 30, 2008 Author Share Posted March 30, 2008 I got him to install WAMP and he said it works now What he was using must have been corrputed or something Link to comment https://forums.phpfreaks.com/topic/98705-question-on-headers-already-sent/#findComment-505150 Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2008 Share Posted March 30, 2008 It is likely that output buffering is now on in his php.ini, where as it was not on before. If you post the actual error message, you will get a lot quicker solution. My guess is the output the error mentions was started on line 1 of the file. If there is no specific white-space, this usually means the file was saved in UTF-8 format and the BOM (Byte Order Mark) characters at the start of the file are being output and this prevents the headers from being sent. If you put these files onto a server where output buffering is not turned on in php.ini, the problem will expose itself again. You need to find and fix the actual problem with the file or with the code. Link to comment https://forums.phpfreaks.com/topic/98705-question-on-headers-already-sent/#findComment-505155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.