error (probably) caused by PHP config on the server

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Gunner
Posts: 276
Joined: Sun Aug 14, 2011 12:07 am

error (probably) caused by PHP config on the server

Post 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? :cry:

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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :cry:

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/
Skype: mrvictordiaz
User avatar
Gunner
Posts: 276
Joined: Sun Aug 14, 2011 12:07 am

Re: error (probably) caused by PHP config on the server

Post 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
Skype: mrvictordiaz
User avatar
Gunner
Posts: 276
Joined: Sun Aug 14, 2011 12:07 am

Re: error (probably) caused by PHP config on the server

Post by Gunner »

helpp.. is revamping the whole thing the only option i have
Skype: mrvictordiaz
User avatar
Gunner
Posts: 276
Joined: Sun Aug 14, 2011 12:07 am

Re: error (probably) caused by PHP config on the server

Post 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 :?
Skype: mrvictordiaz
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: error (probably) caused by PHP config on the server

Post 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.
User avatar
MikuzA
Posts: 395
Joined: Thu Aug 08, 2013 8:57 am

Re: error (probably) caused by PHP config on the server

Post 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!
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
Post Reply

Return to “Beginner Help and Support”