3

I keep getting the error message below. This problem does not exist on my localhost(xampp). It is when the files are on the server that I get this problem.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/plosta/public_html/bloom/Connections/bloom.php:1) in /home/plosta/public_html/bloom/signin.php on line 158

this happens on the server but not on the localhost

<?php
//bloom.php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_bloom = "localhost";
$database_bloom = "datacenter";
$username_bloom = "root";
$password_bloom = "";
$bloom = mysql_pconnect($hostname_bloom, $username_bloom, $password_bloom) or trigger_error(mysql_error(),E_USER_ERROR); 
?>
yu_sha
  • 4,290
  • 22
  • 19

7 Answers7

0

The error says it all, you have session_start() on line 158, try to add it on top of your file.

Ferrmolina
  • 2,737
  • 2
  • 30
  • 46
Matheno
  • 4,112
  • 6
  • 36
  • 53
0

Start your session at top of your page.

<?php 
//before that noting
session_start();


// Your code here
?>
Yatin Mistry
  • 1,246
  • 2
  • 13
  • 35
0

Make sure session_start() must be at the top of your code. Move it form line 158 to line 1

Ferrmolina
  • 2,737
  • 2
  • 30
  • 46
Engineer
  • 5,911
  • 4
  • 31
  • 58
0

seems like you are including some php and be sure that your Connections/bloom.php line:1 has no a line breake, white space, html etc. yeah everyone said move your session_start() to line:1 but i think they ment you should move it to top of your all flow's line:1 not only in the signin.php

Santa's helper
  • 976
  • 8
  • 21
  • i have added the code inside bloom.php under the question. can you please examine it for me? – user3886042 Sep 15 '14 at 07:46
  • if your signin.php includes bloom.php then try to remove the php end tag. remove this "?>" from your bloom.php and be sure that your mysql connection is not throwing any warnings – Santa's helper Sep 15 '14 at 08:06
  • this is what i have noticed. i cleared all code in the signin.php and tried. js returned a normal size alert box. i the inputed and js returned an alert box with a different size which means it bloom .php echo something but is actually invisble. how do i solve this? – user3886042 Sep 15 '14 at 08:25
  • be sure that there is no white space or un-printable charters in your bloom.php before the " – Santa's helper Sep 15 '14 at 08:58
0

ob_start(); ob_flush();

put <?php ob_start(); ?> at top of the file signin.php and <?php ob_flush();?> at bottom of the file sigin.php

coDe murDerer
  • 1,858
  • 4
  • 20
  • 28
0

Usually, when it says "headers already sent" It means that you already started the "ouput buffering", means that you already started to send text to your user.

If it's unintentional (your are not in your code header setup), check for few things, for exemple :

  • A line or character before the "< ?php" of one of your file
  • An echo you forget somewhere in your code.
Bactisme
  • 1,644
  • 2
  • 15
  • 16
  • this is what i have noticed. i cleared all code in the signin.php and tried. js returned a normal size alert box. i the inputed and js returned an alert box with a different size which means it bloom .php echo something but is actually invisble. how do i solve this? – user3886042 Sep 15 '14 at 08:24
  • You could either move your require_once (or put this in a function, call it after), or encapsulate with ob_start/ob_get_clean and the echo the result of the ob_get_clean, later in your code, after your header setup – Bactisme Sep 16 '14 at 09:30
0

you can tried with the below solutions :

  1. Place the line of code <?php ob_start(); ?> at top of you file

  2. check with your signin.php file , session_start() must be at the top of your code. Move it form line 158 to line 1

  3. Please check with your code if you print any variable/array using echo or print , please remove that

if you can paste the whole code of the file , it will be more clear for us to give you proper solution quickly.

Hardy Mathew
  • 684
  • 1
  • 6
  • 22