Jump to content

[SOLVED] Very odd Session_Start() Problem. I'm Stumped. ..


Recommended Posts

Ok, I'm using PHP5.1xxxx, on Apache.. I don't know what could be causing this but,

 

On one certain script, everytime I call Session_Start(); I get the 'headers already sent out', error... However, There is most Definitely nothing being outputted to the page beforehand. I can't figure this out, everything is working fine elsewhere..

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/j/s/c/jscix/html/echains/register/index.php:1) in /home/content/j/s/c/jscix/html/echains/register/index.php on line 2

 

You can see it here:

 

http://www.bawk.org/echains/register/index.php

 

 

This the the script, nothing comes before this.

<?php
session_start();  
include "../includes/DBClass.php";
$Submited = ($_POST['submit']);
$errors = Array();
etcetc .. so on and so fourth..

 

 

.... *Scratches head*

Hi, I guarantee you that you do have something output before the session_start(), otherwise you would not get that warning.

 

Any hidden characters, spaces, HTML, etc. before "<?php" could cause this warning. Also, if there's any output (echo/print) inside the PHP tags before the session_start() would do it too.

 

I know you say that's the script and nothing else, but please double check. Make sure each include file you're using doesn't have any spaces before "<?php" or after ending tag "?>".

 

If you can't find the  problem, the way to get around this is to use output buffering, but you should think of that as a band-aid and not the real solution. Use ob_start() before the session_start(). PHP.net page:

 

http://us3.php.net/manual/en/function.ob-start.php

 

hth.

 

 

I guess Zend Studio automatic saves UTF-8 without the BOM? I've set the default document format in Notepad++ to UTF-8 without BOM. Maybe the BOM should be added to the sticky "headers already sent" thread? If it isn't already..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.