feroz_rk Posted July 25, 2007 Share Posted July 25, 2007 Hello everyone, I have this error comming up in the hosting server and not in my local box. I know this is a simple error but i am not able to find a fix even after a lot of googling. Can some one help me to fix this issue. Its very urgent. Thanks in advance for your advices. Error ***** Cannot modify header information - headers already sent by (output started at /home/carnatik/public_html/apothem/library/config.php:6) in /home/carnatik/public_html/apothem/login.php on line 14 Code **** <?php session_start(); $errorMessage = ''; if (isset($_POST['schoolname'])) { include 'library/config.php'; include 'library/opendb.php'; $schoolname = $_POST['schoolname']; $sql = "SELECT schoolname FROM registration WHERE schoolname = '$schoolname'"; $result = mysql_query($sql) or die('Query failed.' . mysql_error()); if (mysql_num_rows($result) == 1) { $_SESSION['db_is_logged_in'] = true; header('Location: schoollist.php'); exit; } else { $errorMessage = 'Error: Please check the school name / Register again'; } include 'library/closedb.php'; } ?> Quote Link to comment Share on other sites More sharing options...
xylex Posted July 25, 2007 Share Posted July 25, 2007 Your error message says that there's something being outputted to the browser at line 6 of your config.php. A blank line after your closing "?>" ? Post your config.php if you can't figure it out. Quote Link to comment Share on other sites More sharing options...
dg Posted July 25, 2007 Share Posted July 25, 2007 u must be echoing something before the header ..... just check in the included files Quote Link to comment Share on other sites More sharing options...
feroz_rk Posted July 25, 2007 Author Share Posted July 25, 2007 Dear xylex & dg, Thanks for your response. These are my include files config.php ******** <?php $dbhost = 'localhost'; $dbuser = 'carnatik_root'; $dbpass = ''; $dbname = 'carnatik_apothem'; ?> opendb.php ********* <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> Quote Link to comment Share on other sites More sharing options...
plutomed Posted July 25, 2007 Share Posted July 25, 2007 add right at the top of the page before any code: <? ob_start(); ?> and at the bottom after all code: <? ob_end_flush(); ?> Quote Link to comment Share on other sites More sharing options...
feroz_rk Posted July 26, 2007 Author Share Posted July 26, 2007 Dear plutomed, Thank you so much for your time and help. The issue is fixed now. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.