Jump to content

Header not loading


Johnnyboy123

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.