Jump to content

Header redirection issue.


iMoon

Recommended Posts

I am having an issue with some scripts on my site. It won't redirect and emits an error. This occurs for only some of my scripts, but for the ones in which it does occur, it occurs 100% of the time. On a previous server, I didn't have this issue, now I do.

I get the following error:

Warning: Cannot modify header information - headers already sent by (output started at /www/zzl.org/f/a/n/fantasyboxingonline/htdocs/bg/train_stat.php:5) in /www/zzl.org/f/a/n/fantasyboxingonline/htdocs/bg/train_stat.php on line 29

Below is the code to the page that emitted the error above (Note: session_start(); IS in autoupdater.php I'm not that stupid):

<?php
require_once("../autoupdater.php");
?>
<link rel="stylesheet" type="text/css" href="/style.css"/>
<?php
if(!$_SESSION["loggedin"]) {
die("<b>You are not logged in, or you have been logged out. Please <a href=\"/login/\" target=\"_top\">login again!</a></b>");
}
$id = $_GET["id"];
if($id > 4 || $id < 1) {
die("<center><h2>An error occurred. You are trying to train an invalid statistic.</h2></center>");
}
$userid = $_SESSION["userid"];
$time = time();
$stattraining = $_SESSION["stattraining"];
if($stattraining) {
if($stattraining == 1) {
$statname = "powerful";
} elseif($stattraining == 2) {
$statname = "quick";
} elseif($stattraining == 3) {
$statname = "skilled";
} elseif($stattraining == 4) {
$statname = "durable";
}
die("<center><h2>You cannot train! You are already training $statname!</h2></center>");
}
mysql_query("UPDATE `users` SET `stattraining`='$id', `statstarttime`='$time' WHERE `userid`='$userid'", db_connect_select());
header("Location: training.php");
die();
?>

Any help or suggestions would be greatly appreciated.

-Moon

Link to comment
Share on other sites

You'd be better of to make the logic of the script such that buffering isn't needed. All you really need to do is remove the <link rel= . . . for the stylesheet. If you want to style the <h2>s in the die()s, echo the link before the die(), or in this case, I don't see a problem just using an inline style declaration.

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.