Page 1 of 1
error (probably) caused by PHP config on the server
Posted: Mon Mar 02, 2015 1:13 pm
by Gunner
So I just bought a new domain and a hosting plan, and I ran into some prob here....
I got this error
Code: Select all
Warning: session_start() [function.session-start]: Cannot send session cache limiter blahblahblah
URL:
http://furion.xevantgames.com/login.php
But it just runs normally when I use my own host locally.. or even other free hosting on the internet.. could it be that I just wasted my money?
So been googling around and the problem could be in the PHP configuration file
OK, got it, gonna fix it now.
10 minutes later, still trying to find the PHP.INI file
hmmm still can't seem to be able to find it..
1 hour later.. still cant find it
OK lets try seeking around CPANEL.. gotcha! theres a link called "PHP Configuration" yay.. I just fixed it!
OH WAIT... IT FREAKING SAYS: "These PHP configuration settings are customizable by the server administrator. They are listed for reference only."
HOLY CRAP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I hope I was wrong and it can be fixed?
references:
http://board.phpbuilder.com/showthread. ... ready-sent
https://www.ostraining.com/blog/coding/phpini-file/
Re: error (probably) caused by PHP config on the server
Posted: Mon Mar 02, 2015 1:15 pm
by Gunner
I swear it works 100% on my localhost.. or even on other free hosting..
http://furion.weby.biz/login.php uses the exact same script files as
http://furion.xevantgames.com/login.php
Re: error (probably) caused by PHP config on the server
Posted: Tue Mar 03, 2015 1:52 am
by Gunner
helpp.. is revamping the whole thing the only option i have
Re: error (probably) caused by PHP config on the server
Posted: Tue Mar 03, 2015 2:39 am
by Gunner
LOL ok fixed just by adding ob_start().. but WHY??! I didn't even output anything to the browser yet and I got that stupid header error..
here is my first-34-line of code
Code: Select all
<?php
ob_start();
session_start();
include "connect.php";
if (isset($_POST['submit'])){
$username = mysql_real_escape_string($_POST['username']);
$password = md5($_POST['password']);
if ($_POST['username']==''){
$Error = "<span>Username can't be empty</span>";
} else if ($_POST['password']==''){
$Error = "<span class='Error'>Password can't be empty</span>";
} else {
$CheckingName = "SELECT `name` FROM `players` WHERE `name`='$username'";
$CheckingNameQuery = mysql_query($CheckingName);
$CheckingNameFetching = mysql_fetch_array($CheckingNameQuery) or die (mysql_error());
if ($CheckingNameFetching){
$CheckingPassword = mysql_fetch_array(mysql_query("Select password from players where password='$password'"));
if ($CheckingPassword){
$_SESSION['player']=$username;
header('Location: dorf1.php'); // the error is here wthout the ob start!!! and it says I have sent the header on line 1, and wtf line 1 is only '<?php'!!
exit;
} else {
$Error = "<span class='Error'>Password is wrong</span>";
}
} else {
$Error = "<span class='Error'>Username not found</span>";
}
}
}
include "ex/site_data.php";
include "ex/misc_main_inf.php";
include "ex/misc_js1.php";
?>
PHP 5 is confusing the hell outta me

Re: error (probably) caused by PHP config on the server
Posted: Tue Mar 03, 2015 5:13 pm
by Xaleph
It has everything to do with output being sent to output ( like the echo`s etc ) while later on, still sending header data. Hence the "headers already sent" message. You can use ouput buffers to capture all output and echo it at the end, however, it also means there`s a problem in your code.
It usually means something simple like having a blank space in your code somewhere ( maybe your includes ) before the <?php or after the ?>. If you include those before starting the session, you have already sent output to the browser before you start your session which is not allowed. Because you already sent headers ( plain/text or plain/html whatever ) but, if you didnt sent a blank space or \n it means you can still sent headers.
Re: error (probably) caused by PHP config on the server
Posted: Wed Mar 04, 2015 12:07 pm
by MikuzA
session_start() needs to be the first thing written to the 'page'.
Same as in location().
example:
Doesn't work:
Code: Select all
<?PHP
echo "hello";
session_start();
?>
Works:
Code: Select all
<?PHP
session_start();
echo "hello";
?>
Usually it's something with the includes that mess this up, as Xaleph mentioned.
Code: Select all
<?PHP
include sql.php;
include config.php;
session_start();
?>
Just move it first.
Oh and, there should not be anything before the <?PHP also!