Hey Guys tried to find out why I am getting this Error in my Production server. in localhost everything is fine. can anyone please tell me why this happens and what is its solution ? [/B][/B][/B] [B]Warning: Cannot modify header information - headers already sent by (output started at /home/root/public_html/mysite.com/insert_bill_ie.php:12) in[/B][B]/home/susheel/public_html/[B]mysite.com[/B]/insert_bill_ie.php on line [B]213 Code (markup):
Hey jestep Thanks for your reply !! Here is the content code <?php if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "insertform")) { $insertSQL = sprintf("INSERT INTO bill_i_e (type, ms, clearing_chrgs, shippedper, beno, blno,billno, pod, noofqty, bedate, billdate) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s)", GetSQLValueString($_POST['type'], "text"), GetSQLValueString($_POST['ms'], "text"), GetSQLValueString($_POST['clearingchrgs'], "text"), GetSQLValueString($_POST['shipedper'], "text"), GetSQLValueString($_POST['beno'], "text"), GetSQLValueString($_POST['blno'], "text"), GetSQLValueString($_POST['billno'], "text"), GetSQLValueString($_POST['pod'], "text"), GetSQLValueString($_POST['noofqty'], "text"), GetSQLValueString($_POST['bedate'], "date"), GetSQLValueString($_POST['billdate'], "date")); $billno=$_POST['billno']; mysql_select_db($database_connection, $connection); $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error()); $insertGoTo = "insert_bill_ie.php?billno=$billno"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> Code (markup):
Very simple solution. At the top of the file, on the lime immediately after <?php, add: ob_start(); (If there's a single character - even a space - after the <?php, other than the newline, it won't work no matter what else you do. Since you seem to have one blank line at the top of your code, headers are sent at that point. When the code reaches header(sprintf("Location: %s", $insertGoTo)); it blows up, because you can't send headers after they've been sent. Turning on the output buffer (ob_start() is output_buffer_start) fixes the problem, since nothing gets sent until you flush the buffer or run off the page.