-1

I'm new to Website developing and php coding. I need some help figuring out an issue with my website's index.php file. Yesterday, my hosting company moved my website from an old server to a new server with a new IP address and now my website is not working correctly. My first page of the website loads correctly but I'm seeing Warning messages in the background stating Warning session start () which are pointing to my index.php on line 2. When page 2 of the website is activated it does not load correctly and the same Warning messages appear in the background. Not sure how to fix it.

Warning: session_start() [function.session-start]: open(/home/content/89/2527889/tmp/sess_69n0egl5ifdqhpavegcl6kt6b5, O_RDWR) failed: No such file or directory (2) in /home/content/89/2527889/html/index.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/89/2527889/html/index.php:2) in /home/content/89/2527889/html/index.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/89/2527889/html/index.php:2) in /home/content/89/2527889/html/index.php on line 2

Warning: Unknown: open(/home/content/89/2527889/tmp/sess_69n0egl5ifdqhpavegcl6kt6b5, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0

PHP Code:

<?php session_start();

// GET VAIRABLES
if(!empty($_GET['lang'])) { $lang = $_GET['lang']; } else { $lang = ""; }
if(empty($_GET['page'])) { $page = "1"; } else { $page = $_GET['page']; }
$rpt="KPHX";


// GET SCRIPTS
require("scripts/php/functions/church_years.php");
require("scripts/php/functions/define_sermon_hits.php");
require("scripts/php/functions/define_sermon_title.php");
require("scripts/php/functions/define_sermon_link.php");
require("scripts/php/database_credentials.php");
require("scripts/php/languages.php"); 
require("scripts/php/page_titles.php");
require("scripts/php/set_banner.php");
require("scripts/php/store_status.php");

if($page == 1 and empty($lang)) {
    $lang_pti = "Phoenix Tabernacle, INC.";
    $lang_meta = "Welcome Phoenix Tabernacle, INC. Bienvendio al Tabernaculo 
Phoenix, INC.";
}


// SET FRAMEWORKS
$fw["1"]  = "home";
$fw["2"]  = "church";
$fw["3"]  = "pastor";
$fw["4"]  = "leadership";
$fw["5"]  = "calendar";
$fw["6"]  = "sermons";
$fw["7"]  = "donations";
$fw["8"]  = "contact";
$fw["9"]  = "missionary";
$fw["10"] = "streaming";
$fw["11"] = "join";

?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Pragma" content="no-cache" /> 
    <meta http-equiv="expires" content="0" /> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="Language" content="<?php echo $lang_meta; ?>" /> 
    <title><?php echo $lang_pti; ?></title>
    <link href="scripts/css/master.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript" 
src="scripts/js/div_toggle.js"></script>
    <script type="text/javascript" language="javascript" 
src="scripts/js/sidebar_toggle.js"></script>
    <script type="text/javascript" language="javascript" 
src="scripts/js/ibox.js"></script>
    <script type="text/javascript" language="javascript" 
src="scripts/js/menu.js"></script>
    <script type="text/javascript" language="javascript" 
src="scripts/js/join.js"></script>
    <script><?php require("scripts/php/countdown.php"); ?></script>
    <script type="text/javascript" language="javascript" 
src="scripts/js/countdown.js"></script>
    <script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? 
"https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
        try {
        var pageTracker = _gat._getTracker("UA-4143795-2");
        pageTracker._trackPageview();
        } catch(err) {}
    </script>
</head>
<body onLoad="countDown()">
    <div class="wrapper" align="center">
        <div class="body">
        <?php 
        if(empty($lang)) {
            require("framework/language.php");
        } else {
            // HEADER
            require("scripts/php/layout_header.php");
            // BODY
            if(!file_exists("framework/".$fw[$page].".php")) {
                echo "<error>We Apologize But The Page Could Not Found. (404)</error>";
            } else {
                require("framework/".$fw[$page].".php"); 
            }

        // FOOTER
        require("scripts/php/layout_footer.php");
        }
        mysql_close($link);
        ?>
        </div>
    </div>
</body>
</html>    
karthikr
  • 97,368
  • 26
  • 197
  • 188
S TP
  • 1
  • 3
  • Is this `FATAL ERROR syntax error, unexpected 'is' (T_STRING) on line number 2 ` actually in your file? – Enstage May 18 '17 at 23:00
  • You need the full error. The "unexpected" errors don't just say "on line 2". They say "in file xxxxxxxx on line #". We need to know which file caused the error and then you need to show us what is in that file. Look at all those require statements. Any of those files could have the error. – kainaw May 18 '17 at 23:07
  • You probably have mismatched quotes somewhere. – Barmar May 18 '17 at 23:08
  • Warning: session_start() [function.session-start]: open(/home/content/89/2527889/tmp/sess_69n0egl5ifdqhpavegcl6kt6b5, O_RDWR) failed: No such file or directory (2) in /home/content/89/2527889/html/index.php on line 2 – S TP May 19 '17 at 00:00
  • Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/89/2527889/html/index.php:2) in /home/content/89/2527889/html/index.php on line 2 – S TP May 19 '17 at 00:03
  • Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/89/2527889/html/index.php:2) in /home/content/89/2527889/html/index.php on line 2 – S TP May 19 '17 at 00:04
  • Warning: Unknown: open(/home/content/89/2527889/tmp/sess_69n0egl5ifdqhpavegcl6kt6b5, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 – S TP May 19 '17 at 00:04
  • Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0 – S TP May 19 '17 at 00:04
  • Sorry my mistake - the "FATAL ERROR syntax error, unexpected 'is' (T_STRING) on line number 2" is not suppose to be in the file. I'm new using this website. Currently at my website I am seeing these error as the website loads. – S TP May 19 '17 at 00:07
  • Possible duplicate of [Warning: session\_start() failed: No such file or directory](http://stackoverflow.com/questions/3262727/warning-session-start-failed-no-such-file-or-directory) – HPierce May 19 '17 at 01:12

2 Answers2

0

The first issue is that you've sent output to the browser before starting a session.

Put the <?php session_start(); at the very top of the page, with nothing before it. That should get rid of your session start issues.

As per http://php.net/manual/en/function.session-start.php

"To use cookie-based sessions, session_start() must be called before outputing anything to the browser."

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • Thank you - since this is all new to me where would I put the " at? – S TP May 18 '17 at 23:59
  • Thank you - I implemented your advice but it had not effect. I'm sorry maybe it not clear what I wrote previously in my post. I updated my post with more details about the warning statements seen at the website. Any help you can provide would be great appreciated. Thank you again. – S TP May 19 '17 at 00:46
0

Thank you to everyone who posted a comment. I'm thankful you took the time to read through my post to try to guide me. I figured it out. My hosting company is GoDaddy.com and they moved my website to a new server with a new IP address which automatically caused my website not to load correctly. The new server was not running the php files correctly so I had to make the following changes. I had to go through all the website files starting at index.php and change the "session_start();" to "session_save_path("/tmp"); session_start();" in every file that contained "session_start();" Then I created a tmp folder in my root directory. After I made these changes, my website was up and running without any issues.

S TP
  • 1
  • 3