|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 573
|
Help me with this wwarning "Warning:session_start()"
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home3/nyhungry/public_html/includes/header.php:7) in /home3/nyhungry/public_html/includes/header.php on line 57
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home3/nyhungry/public_html/includes/header.php:7) in /home3/nyhungry/public_html/includes/header.php on line 57 ( Hungers) Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" href="stylesheets/webpageprueba.css" rel="stylesheet" media="all" />
<title>www.Nyhungry.com</title>
<script type="text/javascript" src="scripts/prototype.js"></script>
<script type="text/javascript" src="scripts/rating.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
(
function()
{
var default_image = $('td.largethumb img').attr('src');
$('table.smallthumbs a').mouseover(function() { $('td.largethumb img').attr('src', $('img', this).attr('src')); });
});
</script>
</head>
<body>
<div id="sidebar1">
<ul id="mainNav">
<li id="home"><a href="restaurants/index.php" title="All restaurants inside nyhungry" class="first">Home</a></li>
<li id="music"><a href="../../Take Outs/Take Outs frontpage.html" title="Information about all take Outs">Hungry for Music!</a></li>
<li id="pizzerias"><a href="../../Pizzeria/Pizzeria frontpage.html" title="All the pizzerias inside nyhungry">Contact us</a></li>
</ul>
<!-- end #sidebar1 --></div>
<!--<table id="restaurantview">
<a href=""><td width="40" id="contenido1">tropiezo></td></a>
<a href=""><td width="40" id="contenido2">colozar1></td></a>
<a href=""><td width="40" id="contenido3">colozar2></td></a>
<a href=""><td width="40" id="contenido4">colozar3></td></a>
<a href=""><td width="40" id="contenido4">colozar4></td></a>
<a href=""><td width="40" id="contenido4">colozar3</td></a>
</table>-->
<div id="right">
<?php /*?><?php
$data=file_get_contents('counter.dat');
$counter=unserialize($data);
$counter[$_SERVER["REMOTE_ADDR"]]=time();
foreach ($counter as $key => $value) if ($value < (time()-180)) unset $counter($k);
$data=serialize($counter);
file_put_contents('counter.dat', $data);
echo'<p>count($counter)." viewing"</p>';
?> </div><?php */?>
<?php
session_start(); // this is Line 57 where the warning is coming from...
/* Define how long the maximum amount of time the session can be inactive. */
define("MAX_IDLE_TIME", 3);
function getOnlineUsers(){
if ( $directory_handle = opendir( session_save_path() ) ) {
$count = 0;
while ( false !== ( $file = readdir( $directory_handle ) ) ) {
if($file != '.' && $file != '..'){
// Comment the 'if(...){' and '}' lines if you get a significant amount of traffic
if(time()- fileatime(session_save_path() . '\\' . $file) < MAX_IDLE_TIME * 60) {
$count++;
}
}
closedir($directory_handle);
return $count;
}
}
else {
return false;
}
}
echo '(' . getOnlineUsers() . ' viewer)<br />'; ?>
</div>
|
|
|
|
|
|
#2 |
|
SitePoint Enthusiast
![]() Join Date: Oct 2009
Posts: 81
|
You need to have session_start() right at the top of the page.
ie. <?php session_start(); ?> THEN <!DOCTYPE... etc |
|
|
|
|
|
#3 |
|
Computer Slayer
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jul 2003
Location: Northeastern USA
Posts: 1,287
|
In order for a session to be started, no output can be sent to the browser yet. This also means that if you print out PHP error messages before session_start(), you'll get the same error as well.
|
|
|
|
|
|
#4 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: May 2007
Location: Poole, UK
Posts: 822
|
There is nothing wrong with the script as posted, I tried it locally and did not get any errors so possibly something is wrong with the OPs setup. co.ador is the script you posted in a include used by another file, if it is the culprit is most likely in the other file.
|
|
|
|
|
|
#5 | |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jul 2008
Posts: 4,770
|
Quote:
http://www.php.net/manual/en/ref.outcontrol.php This is probably turned on automatically in your configuration files. |
|
|
|
|
|
|
#6 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 573
|
what is the OPs setup?
Yes the script I have put is included in another file, is that the cause of the problem? I include that script in another file. What is the culprit? Hope this can be solved... |
|
|
|
|
|
#7 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Dec 2005
Posts: 672
|
Zend Framework utilizes the
<?php //code goes here pattern, leaving the (?>) closing tag and its main purpose is to avoid the unecessary space outputs. |
|
|
|
|
|
#8 | |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 573
|
space outputs.
I have downloaded the script and analyzed and i notice the ?> closing tag was missing. i thought they have don't a mistake so i put it back again. Well now with the ?> closing tags and the script code below this is the error that comes alone. Quote:
PHP Code:
|
|
|
|
|
|
|
#9 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: May 2007
Location: Poole, UK
Posts: 822
|
You've got the ' in the wrong place:
PHP Code:
PHP Code:
|
|
|
|
|
|
#10 | |||
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 573
|
When I do it like you last suggested then this parse error come up
Quote:
Quote:
the three requests to the data base fail The Insert: PHP Code:
PHP Code:
PHP Code:
PHP Code:
Quote:
The connection i have set up goes as follows it stars with including constant.php in connection.php constant.php PHP Code:
PHP Code:
PHP Code:
is the connection alright? |
|||
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 04:28.










Hybrid Mode
