Johnnyboy123 Posted August 11, 2011 Share Posted August 11, 2011 Hey guys, sorry I know this is a question that has been asked alot, but after googling for solutions I still haven't solved it. Basicly my situation is, I copied my php files from my pc to my laptop. On my pc I used easyphp and on my laptop I use XAMPP. Now all the code is untouched so what works on my pc should work on my laptop. All works fine except I get a header error when running the code from my laptop using XAMPP. Heres the error: Warning: Cannot modify header information - headers already sent by (output starter at C:\xampp\htdocs\test\includes\functions.php:3) in C:\xampp\htdocs\test\editsuccess.php on line 17. Heres my code: <?php include 'includes/config.php'; include 'includes/functions.php'; connect(); if(isset($_POST['submit'])) { $u = "UPDATE course SET `cname` = '$_POST[cname]' WHERE cid = $_POST[cid]"; mysql_query($u) or die(mysql_error()); header( "refresh:5;course_man.php" ); echo 'Update <b> successful </b> You\'ll be redirected in about 5 secs. If not, click <a href="course_man.php">here</a>.'; } ?> Like I said I don't see a white space problem, unless I'm missing it. Also as for the error message, I don't recall using any header functions from my functions.php file so I dont know why it's referring to that. I also tried using a strange function obs_in() at the beginning and obs_flush() or something like that, at the end of my code which someone recommends. It took care of the error message but didn't redirect the page. Could this have anything to do with the difference of using it on easyphp and xampp, maybe a php.ini setting? Any help would be greatly appreciated. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 since the only function you call before you try to send the headers is connect() I'm betting you have a mysql connection error. can we see what's in functions.php ? Quote Link to comment Share on other sites More sharing options...
gizmola Posted August 11, 2011 Share Posted August 11, 2011 There is whitespace in functions.php, which was interpreted as output. Once php thinks it sees output, it sends it, and thus the http header has already been constructed and sent. It's really very simple. The problem is in functions.php. One thing that cures this is to leave the ending ?> off scripts you include like class scripts, config scripts or function scripts. At any rate, it could be a spurious newline in there before the starting <?php or some other issue. Quote Link to comment 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.