doforumda Posted March 10, 2010 Share Posted March 10, 2010 hi i create a website when i checked it on my local computer everything was working fine. but when i upload it to webserver then something going wring there with header(). i.e, when the page calls header function it displays this error. Warning: Cannot modify header information - headers already sent by (output started at /home....../profileinfosave.php:10) in /home/......../profileinfosave.php on line 103 please help if you need some more info about this please ask Quote Link to comment https://forums.phpfreaks.com/topic/194738-need-help-with-header-function/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 10, 2010 Share Posted March 10, 2010 From the error message, you have something at or up to line 10 in profileinfosave.php that is sending output that is preventing the header from working. You would need to find and fix whatever is causing that output or you will need to rearrange the code so that the code responsible for sending the header comes before the output. As to why it works on one system and not another, the php.ini output_buffering setting is either ON or is set to a specific value on your development system, thereby hiding the problem and allowing bad code to appear to work. You should turn the output_buffering setting off so that code you develop will work correctly regardless of the output_buffering setting. Quote Link to comment https://forums.phpfreaks.com/topic/194738-need-help-with-header-function/#findComment-1024079 Share on other sites More sharing options...
doforumda Posted March 10, 2010 Author Share Posted March 10, 2010 i cant see anything in my code which i am making output before header here is my code if you can see that output <?php session_start(); ?> <?php if($_POST['save']) { include("dbConnect.php"); //$_SESSION['userid'] = '1'; $sex = addslashes(strip_tags($_POST['sex'])); $showsex = isset($_POST['showsex']); $month = addslashes(strip_tags($_POST['month'])); $day = addslashes(strip_tags($_POST['day'])); $year = addslashes(strip_tags($_POST['year'])); $showbirth = addslashes(strip_tags($_POST['showbirth'])); $currentcity = addslashes(strip_tags($_POST['currentcity'])); $hometown = addslashes(strip_tags($_POST['hometown'])); $homeneighbor = addslashes(strip_tags($_POST['homeneighbor'])); $status = addslashes(strip_tags($_POST['status'])); $interestedin = addslashes(strip_tags($_POST['interestedin'])); $lookingfor = addslashes(strip_tags($_POST['lookingfor'])); $religiousviews = addslashes(strip_tags($_POST['religiousviews'])); $politicalviews= addslashes(strip_tags($_POST['politicalviews'])); $dob = date($year."-".$month."-".$day); $basicinfosave = mysql_query("UPDATE basicinfo SET currentcity='$currentcity', hometown='$hometown', homeneighborhood='$homeneighbor', relationshipstatus='$status', interestedin='$interestedin', lookingfor='$lookingfor', religiousviews='$religiousviews', politicalviews='$politicalviews' WHERE userid='$_SESSION[userid]' ") or die(mysql_error()); if($basicinfosave) { $agesave = mysql_query("UPDATE basicinfo_age SET sex='$sex', dob='$dob', sexprivacy='$showsex', dobprivacy='$showbirth' WHERE userid='$_SESSION[userid]' "); if($agesave) { header("Location: profile.php"); } } } else { header("Location: profile.php"); } ?> in above code i remove html tags but it still give the same error Warning: Cannot modify header information - headers already sent by (output started at /home/...../profileinfosave.php:3) in /home/...../profileinfosave.php on line 48 Quote Link to comment https://forums.phpfreaks.com/topic/194738-need-help-with-header-function/#findComment-1024080 Share on other sites More sharing options...
roopurt18 Posted March 10, 2010 Share Posted March 10, 2010 Line #2 is an empty line, which still counts as output. Quote Link to comment https://forums.phpfreaks.com/topic/194738-need-help-with-header-function/#findComment-1024091 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.