Jump to content

[SOLVED] help - Cannot modify header.


seany123

Recommended Posts

before i started this thread i did look at the FAQ for this but couldn't find the problem...

 

 

im getting this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/www/XXXX.php:10) in /home/www/XXXX.php on line 21

 

 

here is the start of the page...

 

<?php
include("../lib.php");
define("PAGENAME", "gang Admin");
$player = check_user($secret_key, $db);

$error = 0;
include("../gang_include.php"); 
?>

<?php
if($_POST['dmoney'])
{
if($player->money < $_POST['money'])
{
}
else if($player->money >= $_POST['money'])
{	
$query = $db->execute("update `gangs` set `money`=? where `id`=?", array($gang['money'] + $_POST['money'], $player->gang_id));
$query1 = $db->execute("update `players` set `money`=? where `id`=?", array($player->money - $_POST['money'], $player->id));
}
header('Location: ../your_gang/vault.php');
}

include("../templates/private_header3.php");
?>

 

 

 

Link to comment
Share on other sites

Should there be something between the ?> and <?php tags?

 

include("../gang_include.php"); 
?>
<!-- anything here? -->
<?php
if($_POST['dmoney'])

Read my comment. Was there something there? Say HTML? Text? Anything? If not, check your include files to see if you echo-ed anything or if you output some HTML.

Link to comment
Share on other sites

There doesn't need to be anything there, that space is enough to cause output before you try to set a header

 

change this

 

$error = 0;
include("../gang_include.php"); 
?>
   
<?php
if($_POST['dmoney'])
{

 

to this

 

<?php
$error = 0;
include("../gang_include.php"); 

if($_POST['dmoney'])
{

Link to comment
Share on other sites

You might have read the FAQ, but did you then look at your code where the error message states the output is being sent at?

 

The single blank-line after the closing ?> tag and before the next <?php opening tag IS OUTPUT that is sent to the browser -

 

?>
   
<?php

Link to comment
Share on other sites

i just realised that

include("../gang_include.php");

does have a redirect in it...

 

so ive changed the code to this

 

 

<?php
include("../lib.php");
define("PAGENAME", "gang Admin");
$player = check_user($secret_key, $db);
$error = 0;
?>

<?php
$query = $db->execute("select * from gangs where `id`= $player->gang_id");
$gang = $query->fetchrow;
if($_POST['dmoney'])
{
if($player->money < $_POST['money'])
{
}
else if($player->money >= $_POST['money'])
{	
$query = $db->execute("update `gangs` set `money`=? where `id`=?", array($gang['money'] + $_POST['money'], $player->gang_id));
$query1 = $db->execute("update `players` set `money`=? where `id`=?", array($player->money - $_POST['money'], $player->id));
}
header('Location: ../your_gang/vault.php');
}
include("../gang_include.php"); 
include("../templates/private_header3.php");
?>

 

no there is no Html or anything else in between this code.... your seeing exactly what the code looks like...

 

there is html after this php but that shouldnt make any difference...

 

the lib.php include doesnt have anything in it other than php

 

Link to comment
Share on other sites

You might have read the FAQ, but did you then look at your code where the error message states the output is being sent at?

 

The single blank-line after the closing ?> tag and before the next <?php opening tag IS OUTPUT that is sent to the browser -

 

?>
   
<?php

 

 

oh right..

 

ill try remove the space and see what happens.

 

edit: yeah that has sorted the problem out thank you all for the help :)

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.