By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,018 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,018 IT Pros & Developers. It's quick & easy.

Common session_start() error..

P: n/a
I am getting the error message below when ever I try to start my script
on two different servers. I am not getting any errors off of my PC. I
have looked around and found the answer a simple one. I can not stop the
error in my script. The session_start() is the first thing that happens
before any Headers are created. Any one have any suggestions. Include
the start of the code that uses the session var.
Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php:1) in
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php on line 8

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php:1) in
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php on line 8

<?php
/**
*
*
* @version $Id$
* @copyright 2006
*/
session_start();
if(!isset($_SESSION['abbr_letter']))
$_SESSION['abbr_letter'] = 'A';

require_once 'includes/config.inc.php';
require_once 'includes/header.inc.php';
//
// Start a Form
?>
<html>
<head>
<style type="text/css" >
body {
margin-left: 10%; margin-right: 10%;
color: purple;
background-color: #FFFFF2;
}
quote{ background-color: white }
</style>
</head>
<b><FORM NAME="author_abbrv" method="POST" action="<?php echo
$_SERVER['PHP_SELF'];?>"></b>
<input type="radio" name="abbr_letter" value="A" checked="TRUE"
onclick="submit()"A
<input type="radio" name="abbr_letter" value="B" onclick="submit()"B
<input type="radio" name="abbr_letter" value="C" onclick="submit()"C
<input type="radio" name="abbr_letter" value="D" onclick="submit()"D
<input type="radio" name="abbr_letter" value="E" onclick="submit()"E
<input type="radio" name="abbr_letter" value="F" onclick="submit()"F
<input type="radio" name="abbr_letter" value="G" onclick="submit()"G
<input type="radio" name="abbr_letter" value="H" onclick="submit()"H
<input type="radio" name="abbr_letter" value="I" onclick="submit()"I
<input type="radio" name="abbr_letter" value="J" onclick="submit()"J
<input type="radio" name="abbr_letter" value="K" onclick="submit()"K
<input type="radio" name="abbr_letter" value="L" onclick="submit()"L
<input type="radio" name="abbr_letter" value="M"
onclick="submit()"M <br>
<input type="radio" name="abbr_letter" value="N" onclick="submit()"N
<input type="radio" name="abbr_letter" value="O" onclick="submit()"O
<input type="radio" name="abbr_letter" value="P" onclick="submit()"P
<input type="radio" name="abbr_letter" value="Q" onclick="submit()"Q
<input type="radio" name="abbr_letter" value="R" onclick="submit()"R
<input type="radio" name="abbr_letter" value="S" onclick="submit()"S
<input type="radio" name="abbr_letter" value="T" onclick="submit()"T
<input type="radio" name="abbr_letter" value="U" onclick="submit()"U
<input type="radio" name="abbr_letter" value="V" onclick="submit()"V
<input type="radio" name="abbr_letter" value="W" onclick="submit()"W
<input type="radio" name="abbr_letter" value="X" onclick="submit()"X
<input type="radio" name="abbr_letter" value="Y" onclick="submit()"Y
<input type="radio" name="abbr_letter" value="Z" onclick="submit()"Z
<br>
</FORM>
<b><FORM NAME="author" method="POST" action="<?php echo
$_SERVER['PHP_SELF'];?>"></b>
<SELECT NAME="author_pk" SIZE="20" COLS="10" onclick="submit()">

<?php
//
//Check for the first time pass
if( !isset($_POST['abbr_letter']) ) {
$_POST['abbr_letter'] = $_SESSION['abbr_letter'];
}
//
//If already set then reset the local Var to the Session
$_SESSION['abbr_letter'] = $_POST['abbr_letter'];
//
//Setup for the database call for authors by first letter
$sqlcmd = $author_detail_select_by_Letter . $_POST['abbr_letter']
. $author_detail_orderBy;

--
Thanks in Advance... http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ____________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Nov 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Sun, 05 Nov 2006 23:17:19 -0500, IchBin <we******@ptd.netwrote:
>I am getting the error message below when ever I try to start my script
on two different servers. I am not getting any errors off of my PC. I
have looked around and found the answer a simple one. I can not stop the
error in my script. The session_start() is the first thing that happens
before any Headers are created. Any one have any suggestions. Include
the start of the code that uses the session var.

Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php:1) in
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php on line 8

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php:1) in
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php on line 8

<?php
Do you really have this indentation in the script before the <?php tag? If so,
that's where the output is coming from - and that's also backed up by the error
saying the output started on line 1.

It's possible to mask these problems by turning on one of the variants of
output_buffering, but it's best practice to eliminate the output before any
headers are sent so it works with or without buffering. This may explain why
you see it on one setup but not the other - you probably have buffering (or
zlib output compression) turned on.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 6 '06 #2

P: n/a
Andy Hassall wrote:
On Sun, 05 Nov 2006 23:17:19 -0500, IchBin <we******@ptd.netwrote:
>I am getting the error message below when ever I try to start my script
on two different servers. I am not getting any errors off of my PC. I
have looked around and found the answer a simple one. I can not stop the
error in my script. The session_start() is the first thing that happens
before any Headers are created. Any one have any suggestions. Include
the start of the code that uses the session var.

Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php:1) in
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php on line 8

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php:1) in
/home/www/ichbinquotations.awardspace.com/quotes/quotes.php on line 8

<?php

Do you really have this indentation in the script before the <?php tag? If so,
that's where the output is coming from - and that's also backed up by the error
saying the output started on line 1.

It's possible to mask these problems by turning on one of the variants of
output_buffering, but it's best practice to eliminate the output before any
headers are sent so it works with or without buffering. This may explain why
you see it on one setup but not the other - you probably have buffering (or
zlib output compression) turned on.
Thanks Andy that was the problem. Sorry, I am new to PHP and I do not
understand why those four spaces would give me a problem. The "output of
what" is coming from where? It looks like I do have zlib output
compression ala phpinfo().

--
Thanks in Advance... http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ____________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Nov 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.