解析错误:语法错误,意外结束文件(注册脚本)

时间:2012-12-20 19:11:32

标签: php file parsing

我的脚本有问题:S

  

这是错误:解析错误:语法错误,意外的文件结尾

这是完整的代码。我搜索了没有封闭的小鲑鱼或其他东西,但没有找到任何:S 我希望你们中的一些人能找到问题。

<?php
include "header.php";
include "menu.php";
?>
<div class="wrapper">
<table width=100%>
    <td valign=top width=230px>
        <div class="login">
        <form name="register" method="post" action="$_SERVER[PHP_SELF]" onsubmit="return validateregister()">
        <input type="text" name="username" placeholder="Username"/><br />
        <input type="password" name="password" placeholder="Password"/><br />
        <input type="password" name="passwordagain" placeholder="Password again"/><br />
        <input type="text" name="email" placeholder="E-mail"/><br />
        <input type="text" name="mcname" placeholder="Minecraft Name"/><br />
        <?php
        $captchaquery = mysql_query('SELECT * FROM general');
        $captcha = mysql_fetch_array($captchaquery);
        if($captcha['captcha'] == 'enabled')
        {
            require_once('functions/recaptchalib.php');
            $publickey = $captcha['captchapublic'];
            echo recaptcha_get_html($publickey);
        }
        ?>
        <input class="btn" type="submit" name="register" value="Register" />
        </form>
        </div>
    </td>
    <td valign=top>
        <div id="errors" style="width:80%; margin-left:auto; margin-right:auto;"></div>
    </td>
</table>
<?php
if(isset($_POST['register']))
{
    if($captcha['captcha'] == 'enabled')
    {
        require_once('recaptchalib.php');
        $privatekey = $captcha['captchaprivate'];
        $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

        if (!$resp->is_valid) {
        die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")");
    }
    else
    {
    registerUser($_POST['username'], $_POST['password'], $_POST['passwordagain'], $_POST['email'], $_POST['mcname']);
    }
}
include "footer.php";
?>

2 个答案:

答案 0 :(得分:6)

你忘了这句话的结尾括号:

if (!$resp->is_valid) {
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")");
}

答案 1 :(得分:0)

if (!$resp->is_valid) {
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")");

if没有结束大括号。