我是网站开发和PHP编码的新手。我需要一些帮助来解决我网站的index.php文件的问题。昨天,我的托管公司将我的网站从旧服务器移动到具有新IP地址的新服务器,现在我的网站无法正常工作。我的网站的第一页正确加载但我在后台看到警告消息说明警告会话start()指向我在第2行的index.php。当网站的第2页被激活时,它无法正确加载相同的警告消息显示在后台。不知道如何解决它。
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代码:
<?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>
答案 0 :(得分:0)
第一个问题是您在开始会话之前已将输出发送到浏览器。
将elapsed repeat : 65899
elapsed repeatSB: 305171
放在页面的顶部,之前没有任何内容。这应该摆脱你的会话开始问题。
根据http://php.net/manual/en/function.session-start.php
&#34;要使用基于cookie的会话,必须先调用<?php session_start();
,然后才能向浏览器输出任何内容。&#34;
答案 1 :(得分:0)
感谢发表评论的所有人。我很感谢你花时间阅读我的帖子,试着指导我。我想到了。我的托管公司是GoDaddy.com,他们将我的网站移动到一个新的服务器,其新IP地址自动导致我的网站无法正确加载。新服务器没有正确运行php文件所以我不得不进行以下更改。我必须浏览从index.php开始的所有网站文件并更改&#34; session_start();&#34; to&#34; session_save_path(&#34; / tmp&#34;);在session_start();&#34;在包含&#34; session_start();&#34;的每个文件中然后我在我的根目录中创建了一个tmp文件夹。在我做了这些更改后,我的网站启动并运行没有任何问题。