seany123 Posted May 26, 2009 Share Posted May 26, 2009 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"); ?> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 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. Quote Link to comment Share on other sites More sharing options...
gevans Posted May 26, 2009 Share Posted May 26, 2009 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']) { Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 26, 2009 Share Posted May 26, 2009 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 Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 Yeah, when I meant anything there, I meant literally. Quote Link to comment Share on other sites More sharing options...
seany123 Posted May 26, 2009 Author Share Posted May 26, 2009 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 Quote Link to comment Share on other sites More sharing options...
seany123 Posted May 26, 2009 Author Share Posted May 26, 2009 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 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.