另一个..500 个内部服务器 PHP


Another... 500 internal server PHP

一直在阅读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.

我已经查看了一段时间的代码,但仍然找不到问题。

这里有运气吗?

这是我的登录名.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 [周四 5 月 24 11:31:24 2012] [错误] PHP 警告: include(( [function.include]: 打开失败 "/core/inc/init.inc.php"表示包含 (include_path='.:/usr/local/php5.2-suphp/lib/php'( in /home/3/p/pixeltouch/www/book/login.php 在第 2 行,引用者: http://www.pixeltouch.no/book/login.php [2012年5月24日星期四 11:31:24] [错误]PHP 致命错误:调用未定义的函数 valid_credentials(( in/home/3/p/pixeltouch/www/book/login.php on line 22、推荐人:http://www.pixeltouch.no/book/login.php

我相信问题就在这里:

include('/core/inc/init.inc.php');

前导"/"正在尝试包含服务器根目录中的文件。尝试不使用/。在这种情况下,路径应相对于 register.php 所在的目录。