cherankrish Posted November 11, 2006 Share Posted November 11, 2006 while i try to insert a query in to my db php throws a error Warning: Cannot modify header information - headers already sent by (output started at C:\webroot\solutions\post.php:3) in C:\webroot\solutions\post.php on line 58what can i do? Link to comment Share on other sites More sharing options...
Akula_dude Posted November 11, 2006 Share Posted November 11, 2006 Could you post your code? then we might be able to help Link to comment Share on other sites More sharing options...
jlhaslip Posted November 11, 2006 Share Posted November 11, 2006 There is probably either a blank line or an echo or other form of outout being sent before the Header information. The Header MUST be the first thing sent, or it will throw the error as you have received. As suggested, please post some code. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 11, 2006 Share Posted November 11, 2006 This doesn't have anything to do with a query BTW, you are trying to set a cookie, or start the session, or send a header or something after you have already sent output. Link to comment Share on other sites More sharing options...
cherankrish Posted November 13, 2006 Author Share Posted November 13, 2006 //this is my code have a look please<?php$hostname_consolutiondb = "localhost";$database_consolutiondb = "solutions_db";$username_consolutiondb = "root";$password_consolutiondb = "";$consolutiondb = mysql_pconnect($hostname_consolutiondb, $username_consolutiondb, $password_consolutiondb) or trigger_error(mysql_error(),E_USER_ERROR); function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO tbl_question (intcatid, textname, textemail, textheading, textquestion, dtedate, rating, bitapproved) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['intcatid'], "int"), GetSQLValueString($_POST['textname'], "text"), GetSQLValueString($_POST['textemail'], "text"), GetSQLValueString($_POST['textheading'], "text"), GetSQLValueString($_POST['textquestion'], "text"), GetSQLValueString($_POST['dtedate'], "date"), GetSQLValueString($_POST['rating'], "int"), GetSQLValueString($_POST['bitapproved'], "int")); mysql_select_db($database_consolutiondb, $consolutiondb); $Result1 = mysql_query($insertSQL, $consolutiondb) or die(mysql_error()); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo),false);}mysql_select_db($database_consolutiondb, $consolutiondb);$query_rs_category = "SELECT * FROM tbl_category ORDER BY Id ASC";$rs_category = mysql_query($query_rs_category, $consolutiondb) or die(mysql_error());$row_rs_category = mysql_fetch_assoc($rs_category);$totalRows_rs_category = mysql_num_rows($rs_category);?><!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><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Post Question!!</title><link href="stylesheets/tables.css" type="text/css" rel="stylesheet" /><style type="text/css"><!--.style1 { font-size: 24px; font-weight: bold;}.style2 {color: #000000}--></style></head><body><table width="100%" border="0"> <!--DWLayoutTable--> <tr> <td height="48" valign="top"><img src="pagepics/yoohee.gif" width="243" height="46" /></td> <td rowspan="2" valign="top" bgcolor="#EFEFE4"><p><img src="pagepics/input.jpg" width="251" height="252" /></p> <p><span class="style1">Y</span><strong>ou can ask any kind of question in yoohee </strong>solutions IT ,Home,Relationship whetever.but<br /> dont put any nasty questions or badwords.Our world wide useres will answer your question with in few seconds </p> </td> </tr> <tr> <td height="142" valign="top"><form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table> <tr valign="baseline"> <td nowrap="nowrap" align="right">Your Name:</td> <td><input type="text" name="textname" value="" size="60" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Mail ID:</td> <td><input type="text" name="textemail" value="" size="60" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Category:</td> <td><select name="intcatid"> <?phpdo { ?> <option value="<?php echo $row_rs_category['Id']?>"><?php echo $row_rs_category['text_category']?></option> <?php} while ($row_rs_category = mysql_fetch_assoc($rs_category)); $rows = mysql_num_rows($rs_category); if($rows > 0) { mysql_data_seek($rs_category, 0); $row_rs_category = mysql_fetch_assoc($rs_category); }?> </select> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Heading:</td> <td><textarea name="textheading" cols="60"></textarea></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Question:</td> <td><textarea name="textquestion" cols="60" rows="5"></textarea></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input name="submit" type="submit" value="Post Question" /></td> </tr> </table> <input type="hidden" name="dtedate" value="<?=date('Y/m/d');?>" /> <input type="hidden" name="rating" value="2" /> <input type="hidden" name="bitapproved" value="1" /> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> </p></td> </tr> <tr> <th colspan="2" bgcolor="#CCCCCC" ><span class="style2">www.Yoohee.lk<br /> <br /> <br /> </span></th> </tr></table></body></html><?phpmysql_free_result($rs_category);?> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 13, 2006 Share Posted November 13, 2006 The call to the header function is causing the error because output has already been set to the browser. The error message indicates that output starts on line 3, so you probably have blank lines or spaces at the top of your file that you need to remove. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now