“解析错误:语法错误,意外的$结束”为我的单身登记分配 [英] "Parse error: syntax error, unexpected $end" For my uni registration assignment

查看:128
本文介绍了“解析错误:语法错误,意外的$结束”为我的单身登记分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP新手,所以我使用Youtube教程来创建这个脚本,但是上传者似乎已经消失了,所以我不能问他任何问题。我的登录表单似乎工作正常,但注册表单是我遇到的麻烦

I am new to php so I used a Youtube tutorial to create this script, however the uploader seems to have disappeared so I cannot ask him any questions. My login form seems to work fine but the registration form is where I am having trouble

我已经从代码和所有错误else语句中删除所有html以尝试消除错误消息但我似乎无法找到它。错误总是发生在我的脚本结尾处。

I have removed all html from code and all error else statements to try eliminate the error message but I cant seem to find it. Error always occurs at the end of my script.

任何建议

Any suggestions

        <?php

        if ( $_POST['registerbtn'] ) {
    //makes sure email, username is valid
    $getuser = $_POST['user'];
    $getemail = $_POST['email'];
    $getpass = $_POST['pass'];
    $getretypepass = $_POST['retypepass'];

    if (!isset($getuser))
    {
        $error = "user not set ";
    } 

    if ($getuser) {
        if($getemail) {
            if($getpass) {
                if ($getretypepass) {
        require("connection.php");

                            $query = mysql_query("SELECT * FROM          users WHERE username ='$getuser'");
                            $numrows = mysql_num_rows($query);
                            if ($numrows == 0) {
                            $query = mysql_query("SELECT * FROM users WHERE email ='$getemail'");
                            $numrows = mysql_num_rows($query);
                            if ($numrows == 0) {

                                $password = md5(md5("19Dvdnj".$password."jndfFf20"));
                                $date = date("F d, Y");
                                $code = md5(rand());

                                mysql_query("INSERT INTO users VALUES ('', '$getuser', '$password', '$getmail', '0', '$code', '$date')");

                                $query = mysql_query("SELECT * FROM users WHERE username='$getuser'");
                                $numrows =mysql_num_rows($query);
                                if ($numrows == 1) { 

                                $site ="http://www.inn.leedsmet.ac.uk/~c3314283/iis/register.php";
                                $webmaster = "admin@leedsmet.com";
                                $headers = "From: $webmaster";
                                $subject ="Activate your Account";
                                $message = "Thanks for registering. Click below to activate your account.\n";
                                $message .= "$site/activate.php?user=$getuser&code=$code";
                                $message .= "You must activate your account to login";

                                if (mail($getmail, $subject, $message, $headers)){
                                    $errormsg = "You have been registered you must activate your account sent from the the activation link sent to<b>$getemail</b>";
                                    $getuser = "";
                                    $getemail = "";
                                }



                            mysql_close();





        $form ="<form action='register.php' method='post'>
        <table>
        <tr>
    <td></td>
    <td><font color='red'>$errormsg</font></td>
        </tr>

<tr>
    <td>Username:</td>
    <td><input type='text' name='user' value ='$getuser'/></td>
</tr>
    <tr>
        <td>Email:</td>
        <td><input type='text' name='email' value ='$getemail'/></td>
    </tr>
        <tr>
    <td>Password:</td>
    <td><input type='password' name='pass' value =''/></td>
        </tr>       
    <tr>
    <td>Retype:</td>
    <td><input type='password' name='retypepass' value =''/></td>
        </tr>   
    <tr>
    <td></td>
    <td><input type='submit' name='registerbtn' value ='Register'/></td>
        </tr>   
        </table>
        </form>";
        {
        echo $form;
        }
        ?>

推荐答案

尝试autoformating(自动缩进)你的代码。如果你没有一个允许的编辑器,得到一个如 Notepad ++ 。:-)它会为您节省大量时间,而不是在这种情况下尝试找到问题,而在自动配置问题后会盯着你。:-)

Try autoformating (auto-indent) your code. If you do not have an editor that allows that, get one such as Sublime Text or Notepad++. :-) It will save you a lot of time in similar situations; instead of trying to locate the problem in such situations, after autoformating problems will stare you in the face. :-)

我相信你缺少六个左花括号} (不确定我是否计算了未结案的

I believe you are missing around six closing braces } (not sure I counted the number of unclosed ifs correctly) after the

{
    echo $form;
}

显然,如果发生这种情况,可能会发生严重错误, } s可以治愈你r code。

Obviously if this is the case something terribly wrong has happened and it may take more than putting some }s there to heal your code.

这可能是复制和粘贴问题。也许你没有复制在你提到的Youtube教程中找到的代码的最后几行。

This could be a copy&paste problem. Maybe you did not copy the last few lines of the code you found in the Youtube tutorial you mention.

这篇关于“解析错误:语法错误,意外的$结束”为我的单身登记分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆