页面源显示我的页面部分未显示

时间:2013-02-02 04:22:22

标签: php html

我正在处理一个朋友的项目,我负责设计一个简单的网站来与他的数据库进行交互。我为他的一个页面编写了以下代码:

<!DOCTYPE html>

<html>
    <head>
        <title>Narcissus-OTS</title>
        <meta charset="utf-8" />
        <!--<meta http-equiv="refresh" content="3;url=./account.php" />-->
    </head>
    <body>
        <?php include("./common/database.php"); ?>
        <?php
            //Grabs user-submitted credentials from previous page
            $accountid = mysql_escape_string($_POST["acc"]);
            $password = mysql_escape_string($_POST["pass"]);
            $confirmation = mysql_escape_string($_POST["passtwo"]);
            //Insures there is no duplicate database entry for accountid
            $querycheck = $db->query("
                SELECT *
                    FROM accounts a
                    WHERE a.name = $accountid
                ");
            $checkifone = $querycheck->rowCount();
            //If no duplicate entry...
            if ($checkifone == 1) {
                echo "There is already an account with that name; please choose a different account number.";
            } else {
            //Confirms if passwords match
                if ($password == $confirmation) {
                    $passhash = sha1($password);
                    $database = $db->query("
                        INSERT INTO accounts
                            VALUES (NULL , '$accountid', '$passhash', '65535', '0', '', '1', '0', '0', '1');
                    ");
                    echo "Your account has been successfully created.";
                //If passwords do not match
                } else {
                    echo "Your passwords did not match, please try again.";
                }
            }
        ?>
    </body>
</html>         

当我加载页面并查看页面源时,它似乎没有显示终止</body>或终止</html>标记。我已经跟踪了我的代码,看不到任何遗漏的分号或括号。对于我的生活,我无法想象这一个。它仅在密码不匹配时才会正确显示终止标记(最底层嵌套的else语句)。

编辑;在任何人说出来之前,我知道mysql_escape_string已被弃用。

EDIT2; database.php看起来像......

<?php
    $SERVER   = "localhost";
    $USERNAME = "redacted";
    $PASSWORD = "redacted";
    $DATABASE = "redacted";
    $db = new PDO("mysql:dbname={$DATABASE}; host={$SERVER}", $USERNAME, $PASSWORD);
    $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
?>

1 个答案:

答案 0 :(得分:1)

您最好的办法是解决此问题以及将来出现的任何此类问题,请tail您的服务器日志并确定问题究竟是什么。

apache2

tail -f /var/log/apache2/error.log

nginx

tail -f /var/log/nginx/error.log