Page 1 of 1

Including a php file getting error ( 1007: Cannot modify...)

Posted: Mon Sep 20, 2010 4:37 pm
by thomas49th
Hi I have a php file which a html file calls by require_once. I have found that if I include

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = './phpbb/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
i get the error

on line 1007: Cannot modify header information - headers already sent by (output started at

but if I include this piece of code at the top of html file it works fine. What is the reason for this? Is it perhaps that the include common.php file I'm guessing it's searching for includes header functions?

Is there anyway around it

Thanks
Thomas

Re: Including a php file getting error ( 1007: Cannot modify

Posted: Mon Sep 20, 2010 7:23 pm
by requinix

Code: Select all

include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
Any one of those lines can be trying to send a header; my guess would be the session_begin() call. That can't happen if you've already begun outputting stuff.