webclown Posted February 28, 2007 Share Posted February 28, 2007 Hi guys I keep getting error :Cannot modify header information - headers already sent by (output started at C:\wamp\www\Tipping\common.inc:44) in C:\wamp\www\Tipping\common.inc on line 38. But I can't see waht is worng with the code can any one help. code: <?php function connect_db(){ $dbhost = 'localhost'; $dbuser = 'webuser'; $dbpass = 'webpass'; $dbname = 'tipping'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); } function close_con(){ mysql_close(); } function get_cround(){ connect_db(); $sql = ("SELECT * FROM admin"); $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $cround = $row['cround']; } return $cround; } function enterTips(){ $uid = "23"; $round = $_REQUEST['round']; $query = "INSERT INTO tips VALUES('','$uid','$round'"; for($i=1;$i<9;$i++){ $game = "r$round"; $game .="g$i"; $g1 = $_POST[$game]; $query .= ",'$g1'"; } $query .=")"; connect_db(); mysql_query($query); header("location:commservman.php?error=exists"); exit; } ?> sory it is a bit long. Link to comment https://forums.phpfreaks.com/topic/40455-headers-already-sent/ Share on other sites More sharing options...
btherl Posted February 28, 2007 Share Posted February 28, 2007 It's possible you have a space or empty line before your "<?php". I don't see anything in your code that I would expect to generate output. Link to comment https://forums.phpfreaks.com/topic/40455-headers-already-sent/#findComment-195757 Share on other sites More sharing options...
webclown Posted February 28, 2007 Author Share Posted February 28, 2007 Sorry Guy just the another post on this site that fixed the problem. Great site, good help. cheers. Link to comment https://forums.phpfreaks.com/topic/40455-headers-already-sent/#findComment-195759 Share on other sites More sharing options...
webclown Posted February 28, 2007 Author Share Posted February 28, 2007 I have added ob_start() at the start of the script. <?php ob_start(); .... All good. Link to comment https://forums.phpfreaks.com/topic/40455-headers-already-sent/#findComment-195760 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.