azeem123456 Posted February 20, 2010 Share Posted February 20, 2010 i m having problem in redirecting im making content management system i get a values from posted form and then insert as an new row value is inserted correctly but i want to redirect it back to my content.php when i use header("Location: content.php"); it gives me this error when i fill form and hit submit error is "Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\widget_corp\includes\connection.php:1) in C:\xampp\htdocs\widget_corp\create_subject.php on line 14" and my code is <?php $menu_name= $_POST['menu_name']; $position = $_POST['position']; $visible = $_POST['visible']; $query = "INSERT INTO subjects ( menu_name, position, visible) Values ( '{$menu_name}',{$position},{$visible})"; if(mysql_query($query,$connection)){ header("Location: content.php"); exit; }else { echo "<p> Subject creation is failed .</p>"; echo "<p>".mysql_error()."</p>"; } please please help me out Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/ Share on other sites More sharing options...
teamatomic Posted February 20, 2010 Share Posted February 20, 2010 probably some whitespace here \connection.php:1 HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015346 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 no sir there is not problem in it i just check it still it gives me same error some body please help meeee my final date is approaching soon please Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015367 Share on other sites More sharing options...
teamatomic Posted February 20, 2010 Share Posted February 20, 2010 Show the start of connection.php HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015368 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 this is my content.php file i have made nevigation fucntion seperatly and to snow u my content.php i j ust copy paste my function here there might be sysntax errors but i m sure u will get idea ?php require_once("includes/connection.php");?> <?php require_once("includes/functions.php");?> <?php find_selected_page();?> <?php include("includes/header.php"); ?> <table id="Structure"> <tr> <td id="nevigation"> /////////////////////////////////////////////////// echo"<ul class=\"subjects\">"; $subject_set=get_all_subjects(); while ($subject=mysql_fetch_array($subject_set)){ echo "<li<a href=\"content.php?subj=".urlencode($subject["id"])."\">{$subject["menu_name"]}</a></li>"; $page_set = get_pages_for_subject($subject["id"]); echo "<ul class=\"pages\">"; while ($page= mysql_fetch_array($page_set)){ echo "<li><a href=\"content.php?page=".urlencode($page["id"])."\">{$page["menu_name"]}</a></li>"; } echo "</ul>"; } echo" </ul>"; <br /> <a href="new_subject.php"> + ADD a new subject</a> </td> <td id="pages"> <?php if(!is_null($sel_subject)){?><h2><?php echo $sel_subject['menu_name'];?></h2><?php }else if (!is_null($sel_page)){ ?> <h2><?php echo $sel_page['menu_name'];?></h2> <div class= "page_content"> <?php echo $sel_page['content'];?> </div> <?php }else { ?><h2> Select a subject or page to edit</h2> <?php }?> </td> </tr> </table> <?php require("includes/footer.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015371 Share on other sites More sharing options...
teamatomic Posted February 20, 2010 Share Posted February 20, 2010 Again, please post the start of your connection.php file. That is where the error is. Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015374 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 this is my new_subject.php file which has form in it to add new subject ?php require_once("includes/connection.php");?> <?php require_once("includes/functions.php");?> <?php find_selected_page(); ?> <?php include("includes/header.php"); ?> <table id="Structure"> <tr> <td id="nevigation"> <?php navigation($sel_subject,$sel_page); ?> </td> <td id="pages"> <h2> Add Subject</h2> <form action="create_subject.php" method="post"> <p> Subject name:<input type="text" name="menu_name" value="" id="menu_name" /></p> <p> position: <select name="position"> <?php $subject_set= get_all_subjects(); $subject_count= mysql_num_rows($subject_set); for ($count=1;$count<= $subject_count+1;$count++){ echo"<option value=\"{$count}\">{$count}</option>"; } ?> </select> </p> <p> visible : <input type="radio" name="visible" value="0" />No <input type="radio" name="visible" value="1" />YES </p> <input type="submit" value="Add Subject" /> </form> <br/> <a href="content.php">Cancel</a> </td> </tr> </table> <?php require("includes/footer.php");?> //////////////////////////////////////////////////////// when i run this file it works correctly and give me form [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015379 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 after filling form my new file create_subject.php take all information this is code <?php require_once("includes/connection.php");?> <?php require_once("includes/functions.php");?> <?php $menu_name= $_POST['menu_name']; $position = $_POST['position']; $visible = $_POST['visible']; $query = "INSERT INTO subjects ( menu_name, position, visible) Values ( '{$menu_name}',{$position},{$visible})"; if(mysql_query($query,$connection)){ header("Location": "content.php"); exit; }else { echo "<p> Subject creation is failed .</p>"; echo "<p>".mysql_error()."</p>"; } ?> <?php mysql_close($connection);?> it add subject corrctly it add all subjects but it doesnt redirect me bak to my content.php page after adding information it gives error cannot modify header as i mention before Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015381 Share on other sites More sharing options...
teamatomic Posted February 20, 2010 Share Posted February 20, 2010 Azeem You're going to have to wait for someone else to help you. Twice I've asked you to show me the start of the file that is causing the error(connection.php) and I dont seem to be heard. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015383 Share on other sites More sharing options...
greatstar00 Posted February 20, 2010 Share Posted February 20, 2010 if that connection.php is that secret, u dont want to show it we cant help u, cause that error message line (at your 1st post), the message stating the connection.php is having error. if u dont show that, we cant help u if you dont show the file, then we cant help even it is your final second only god can help u here is what i suggest you to do before showing that connection.php use **** to replace the mysql address, username, password, db name Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015384 Share on other sites More sharing options...
jl5501 Posted February 20, 2010 Share Posted February 20, 2010 as people here are trying to tell you, your error message clearly states: output started at C:\xampp\htdocs\widget_corp\includes\connection.php:1) That means that something on line 1 of that file, is producing output. It may be as simple as a space before the <?php or may be something else, but that is where your error is. Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015389 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 oh i read it wrong sir i thought u asking me content.php sir i didnt make seperate db connection file as i m new learner of php so i m not perfect in it there is nothing important for me sir.... all i want to learn and gain knowlegde sir could you tell me your email adress i send you my whole project and file to your email adress then u mite eaisly sort out my problem ths is how i made my dataabase connection sir <?php $connection = mysql_connect("localhost","root",""); if (!$connection){ die ("Database connection failed".mysql_error()); } $db_select= mysql_select_db("widget_corp",$connection); if (!$db_select){ die ("Database selection failed".mysql_error()); } ?> in html body there is my queries as u have seen above i provide you what you just asked me or give me email id please at the end i close my conection ?php mysql_close($connection); ?> Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015391 Share on other sites More sharing options...
jl5501 Posted February 20, 2010 Share Posted February 20, 2010 ok, good, so as you can see, the first thing visible in that file, is the <?php You need to ensure there are no blank lines above that, or spaces in front of the <?php The <?php must be right at the start of the file Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015392 Share on other sites More sharing options...
greatstar00 Posted February 20, 2010 Share Posted February 20, 2010 by reading this code, we cant find the error as u said, u can send the project to email here is mine [email protected] this is only my advertising email, meaning only receive ads, kinda of useless so, u can send this time only i wont check mails here ever after unless requested Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015395 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 i have sent my project azeem rathore is my name i send from hotmail id so kindly check it out please thanks Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015403 Share on other sites More sharing options...
greatstar00 Posted February 20, 2010 Share Posted February 20, 2010 did u checked again as i check your code, it doesnt got any problem it redirects me to content.php well, try to delete the extra line feed after the ?> (the very end) of connection.php (i didnt delete this, and it worked) i am running php 5.3 Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015415 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 i tried still not work could you remove all whitespace for me please and send file again i run on it and check it because i do not think i have left any whitespace ? Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015422 Share on other sites More sharing options...
greatstar00 Posted February 20, 2010 Share Posted February 20, 2010 wat php version you running, maybe i can install that, and try it out php 5.3 has no problem i sent u the new file via email Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015423 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 i am using xampp and writing code on dreamwaver xampp version 2.5.8 well to be ho nest i m new learner so all i know about about version i have told you kindly quide me please Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015425 Share on other sites More sharing options...
greatstar00 Posted February 20, 2010 Share Posted February 20, 2010 as far as i know, xampp's latest version is 1.7.3 from here http://sourceforge.net/projects/xampp/ http://www.apachefriends.org/en/xampp-windows.html all for windows and your version number is most likely xampp control panel 2.5.8 Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015427 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 oh yeh sorry im using xampp 1.7.2 i told you my control panel version thanks for correcting me so do i have to install latest version? Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015429 Share on other sites More sharing options...
greatstar00 Posted February 20, 2010 Share Posted February 20, 2010 as i checked, xampp 1.7.2, it most likely come with php 5.3.0 too just try out my code that i sent u Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015435 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 di du send me on my email adress? i didnt recieve if you are senidng me thorugh yahoo id then sent me [email protected] please i dont know what is porblem in currenly email i d i gave you it doesnt receive emails from yahoo sometime kindly send on [email protected] sorry for inconvience Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015436 Share on other sites More sharing options...
greatstar00 Posted February 20, 2010 Share Posted February 20, 2010 i sent again Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015441 Share on other sites More sharing options...
azeem123456 Posted February 20, 2010 Author Share Posted February 20, 2010 his time same warning is appear but insteade of connection.php is saying create_subject.php Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\widget_corp\create_subject.php:1) in C:\xampp\htdocs\widget_corp\create_subject.php on line 11 check out it was C:\xampp\htdocs\widget_corp\connection.php:1) before now this is in C:\xampp\htdocs\widget_corp\create_subject.php:1) Quote Link to comment https://forums.phpfreaks.com/topic/192747-i-need-help/#findComment-1015443 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.