在 SO 中阅读了几乎所有的错误 500 内部问题,但仍然无法弄清楚我的应用程序是什么。
这是我收到的错误消息..
Server error
The website encountered an error while retrieving http://www.pixeltouch.no/book/register.php. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
我已经查看了一段时间的代码,但仍然找不到问题。
这里有运气吗?
这是我的 login.php
<?php
include('/core/inc/init.inc.php');
$errors = array();
if (isset($_POST['username'], $_POST['password'])){
if(empty($_POST['username'])){
$errors[] = 'The username cannot be empty.';
}
if(empty($_POST['password'])){
$errors[] = 'The password cannot be empty.';
}
//Log in
if (valid_credentials($_POST['username'], $_POST['password']) == false ){
$errors[] = 'Username / Password incorrect.';
}
if (empty($errors)){
$_SESSION['username'] = htmlentities($_POST['username']);
$_SESSION['uid'] = fetch_user_id($_SESSION['username']);
header("Location: profile.php?uid=" . $_SESSION['uid']);
die();
echo $_SESSION['uid'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pixeltouch</title>
<link rel="stylesheet" type="text/css" href="ext/style.css" />
</head>
<body>
<div id="page-wrap">
<div id="main-content">
<br/>
<?php include_once('template/head.inc.php');
?>
<div id="menu">
<?php include_once('template/nav.inc.php');
?>
</div>
<!-- SKRIVBOX-->
<div>
<?php
if(empty($errors) == false){
?>
<ul>
<?php
foreach ($errors as $error) {
echo "<li>$error</li>";
}
?>
</ul>
<?php
}else{
echo 'Need an account ? <a href="register.php">Register here</a>';
}
?>
</div>
<br/>
<form method="post" action="" >
<p>
<label for="username">Username:</label>
<input type="text" name="username" id="username" value="<?php if (isset($_POST['username'])) echo htmlentities($_POST['username']); ?>" />
</p>
<p>
<label for="password">Password: </label>
<input type="password" name="password" id="password" />
</p>
<p>
<input type="submit" value="Login" />
</p>
</form>
<!-- SKRIVBOX END-->
</div>
<?php include_once('template/foot.inc.php');
?>
</div>
</body>
</html>
还有我的 Init.inc.php 文件
<?php
session_start();
mysql_connect("SERVER", "USERNAME", "PASSW") or die(mysql_error()) ;
mysql_select_db("pixeltouch2") or die(mysql_error()) ;
$path = dirname(__FILE__);
include("{$path}/user.inc.php");
?>
<!--Registration/Login (START)-->
<?php
$exceptions = array('register', 'login', 'user_list', 'profile', 'edit_profile');
$page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4);
if(in_array($page, $exceptions) == false){
if (isset($_SESSION['username']) == false){
header('Location: login.php');
die();
}
}
?>
<!--Registration/Login (END)-->
<!--User Profile (START)-->
<?php
$_SESSION['uid'] = 1;
?>
<!--User Profile (END)-->
我从 webb 托管商那里得到了错误日志,上面写着
[2012 年 5 月 24 日星期四 11:31:24] [错误] 警告:include(/core/inc/init.inc.php) [function.include]:无法打开流:/home/3 中没有这样的文件或目录/p/pixeltouch/www/book/login.php 在第 2 行,引用:http : //www.pixeltouch.no/book/login.php [2012 年 5 月 24 日星期四 11:31:24] [错误] PHP 警告: include() [function.include]:无法在 /home 中打开 '/core/inc/init.inc.php' 以包含 (include_path='.:/usr/local/php5.2-suphp/lib/php') /3/p/pixeltouch/www/book/login.php 在第 2 行,参考: http : //www.pixeltouch.no/book/login.php [Thu May 24 11:31:24 2012] [错误] PHP致命错误:在第 22 行的 /home/3/p/pixeltouch/www/book/login.php 中调用未定义函数 valid_credentials(),引用者:http ://www.pixeltouch.no/book/login.php