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);
?>
The error says it all, you have session_start()
on line 158, try to add it on top of your file.
Start your session at top of your page.
<?php
//before that noting
session_start();
// Your code here
?>
Make sure session_start()
must be at the top of your code. Move it form line 158 to line 1
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
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
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 :
you can tried with the below solutions :
Place the line of code <?php ob_start(); ?>
at top of you file
check with your signin.php file , session_start()
must be at the top of your code. Move it form line 158 to line 1
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.