hyde360
07-21-2009, 04:40 AM
Hello,
Right, I got two php files one is the main page that shows everything within a layout and one file called (functions.php) but the problem is I'm including a session.php which I use to check users online/offline and many many other things.
Although, my function object "userBar();" won't recongise the "$session" variable that's in my session.php file, however I've tried including the session.php file within my function object but it throws this error at me:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/main/mypage.php:8) in /path/to/my/session.php on line 48
Which I know what that means, that a session_start() must be performed before any html is outputted which I have done so but for some reason it's still throwing this evil message at me...
Here's what my function file looks like:
<?php
#debugging purposes only
# error_reporting(E_ALL);
//Xbox Daily Function File
// $version : 1.1.0
// $filename : functions.php
// $website : www.xboxdaily.co.uk
//Let"s create the userBar object
//We need to define two vars for our userBar() object.
function userBar() {
require $_SERVER['DOCUMENT_ROOT']."/users/mk/session.php";
if (!$session->logged_in) {
echo '<img alt="not logged in" src="img/user_silhouette.png" /> Welcome <b>Guest</b>, please <a title="login" href="".login_url."">login</a> or <a title="register" href="".register_url."">register</a>.';
} else {
//If they are logged in, then display a nice little welcome note.
echo '
<img alt="logged in" src="img/user.png" /> Welcome back <b>$session->username</b>! <img alt="Community Image" height="16" src="img/page_white_stack.png" width="16" />
<a title="My Community" href="".community_url."/$session->username.html">My Community</a> |
<img alt="Account Image" height="16" src="img/dashboard.png" width="16" />
<a title="My Dashboard" href="".dashboard_url."">My Dashboard</a> |
<img alt="padlock" height="16" src="img/lock_unlock.png" width="16" />
<a title="Sign me out" href="".signout_url."">Sign me out</a> |
<img alt="Pm" height="16" src="img/envelope.png" width="16" />
New messages (undefined)
';
}
}
?>
Before any meantioned about the constants that are not in the script above, I removed them to see if it would solve this issue (they in the script)
And on the page that is including this file looks like this:
...Won't post full script as it's huge :)
<?php include("functions.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-gb" http-equiv="Content-Language" />
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
<meta name="description" content="XboxDaily.co.uk - Your daily resource for Xbox 360 Games, Xbox 360 Videos, Xbox 360 Previews, and much more!!!" />
<meta name="keywords" content="xbox, microsoft, xbox 360, microsoft xbox, microsoft xbox 360, 360, my xbox, game, gaming, games, videos, daily, MS, daily gaming" />
<meta name="author" content="Xbox Daily, Visual Blue" />
<meta name="revised" content="08/02/2009" />
<title>:: Xbox Daily :: Your daily resource for Xbox 360 Games, Xbox 360 Videos,
Xbox 360 Previews...</title>
Also the main code above it's nothing major and doesn't include any other php scripts apart Database connections etc.
If anyone can help shine a light on what's causing this issue, I would appreciate it so much :D
Thanks in advance!
Right, I got two php files one is the main page that shows everything within a layout and one file called (functions.php) but the problem is I'm including a session.php which I use to check users online/offline and many many other things.
Although, my function object "userBar();" won't recongise the "$session" variable that's in my session.php file, however I've tried including the session.php file within my function object but it throws this error at me:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/main/mypage.php:8) in /path/to/my/session.php on line 48
Which I know what that means, that a session_start() must be performed before any html is outputted which I have done so but for some reason it's still throwing this evil message at me...
Here's what my function file looks like:
<?php
#debugging purposes only
# error_reporting(E_ALL);
//Xbox Daily Function File
// $version : 1.1.0
// $filename : functions.php
// $website : www.xboxdaily.co.uk
//Let"s create the userBar object
//We need to define two vars for our userBar() object.
function userBar() {
require $_SERVER['DOCUMENT_ROOT']."/users/mk/session.php";
if (!$session->logged_in) {
echo '<img alt="not logged in" src="img/user_silhouette.png" /> Welcome <b>Guest</b>, please <a title="login" href="".login_url."">login</a> or <a title="register" href="".register_url."">register</a>.';
} else {
//If they are logged in, then display a nice little welcome note.
echo '
<img alt="logged in" src="img/user.png" /> Welcome back <b>$session->username</b>! <img alt="Community Image" height="16" src="img/page_white_stack.png" width="16" />
<a title="My Community" href="".community_url."/$session->username.html">My Community</a> |
<img alt="Account Image" height="16" src="img/dashboard.png" width="16" />
<a title="My Dashboard" href="".dashboard_url."">My Dashboard</a> |
<img alt="padlock" height="16" src="img/lock_unlock.png" width="16" />
<a title="Sign me out" href="".signout_url."">Sign me out</a> |
<img alt="Pm" height="16" src="img/envelope.png" width="16" />
New messages (undefined)
';
}
}
?>
Before any meantioned about the constants that are not in the script above, I removed them to see if it would solve this issue (they in the script)
And on the page that is including this file looks like this:
...Won't post full script as it's huge :)
<?php include("functions.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-gb" http-equiv="Content-Language" />
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
<meta name="description" content="XboxDaily.co.uk - Your daily resource for Xbox 360 Games, Xbox 360 Videos, Xbox 360 Previews, and much more!!!" />
<meta name="keywords" content="xbox, microsoft, xbox 360, microsoft xbox, microsoft xbox 360, 360, my xbox, game, gaming, games, videos, daily, MS, daily gaming" />
<meta name="author" content="Xbox Daily, Visual Blue" />
<meta name="revised" content="08/02/2009" />
<title>:: Xbox Daily :: Your daily resource for Xbox 360 Games, Xbox 360 Videos,
Xbox 360 Previews...</title>
Also the main code above it's nothing major and doesn't include any other php scripts apart Database connections etc.
If anyone can help shine a light on what's causing this issue, I would appreciate it so much :D
Thanks in advance!