分析错误:语法错误,第150行CODE中意外的文件结尾分析CODE错误


Parse error: syntax error, unexpected end of file in CODE on line 150 Errors parsing CODE

我一直在努力解决这个问题。我到处都找过了,但无法解决这个问题。我不是一个很好的程序员,所以我真的不知道出了什么问题。我问过几个人,他们帮我解决了其他错误,然后出现了这个问题,他们帮不上忙。这是一个又一个错误,请帮助。这是wordpress只是为了帮一点忙。

    <?php session_start(); ?>
<?php
/*
Template Name: test
*/
?>
<?php get_header(); ?>
<?php get_template_part( 'framework/inc/titlebar' ); ?>
<div id='page-wrap' class='container'>
        <div id='content' class='sidebar-right twelve columns'>
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <article id='post-<?php the_ID(); ?>' <?php post_class(); ?>>
                        <div class='entry'>
                                <?php the_content(); ?>
                                <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>
                        </div>
                </article>
                <?php if(!$data['check_disablecomments']) { ?>
                        <?php comments_template(); ?>
                <?php } ?>

        </div> <!-- end content -->

        <?php
/*** begin our session ***/
/*** first check that both the username, password and form token have been sent ***/
if(!isset( $_POST['phpro_username'], $_POST['phpro_password'], $_POST['form_token']))
{
    $message = 'Please enter a valid username and password';
}
/*** check the form token is valid ***/
elseif( $_POST['form_token'] != $_SESSION['form_token'])
{
    $message = 'Invalid form submission';
}
/*** check the username is the correct length ***/
elseif (strlen( $_POST['phpro_username']) > 20 || strlen($_POST['phpro_username']) < 4)
{
    $message = 'Incorrect Length for Username';
}
/*** check the password is the correct length ***/
elseif (strlen( $_POST['phpro_password']) > 20 || strlen($_POST['phpro_password']) < 4)
{
    $message = 'Incorrect Length for Password';
}
/*** check the username has only alpha numeric characters ***/
elseif (ctype_alnum($_POST['phpro_username']) != true)
{
    /*** if there is no match ***/
    $message = 'Username must be alpha numeric';
}
/*** check the password has only alpha numeric characters ***/
elseif (ctype_alnum($_POST['phpro_password']) != true)
{
        /*** if there is no match ***/
        $message = 'Password must be alpha numeric';
}
else
{
    /*** if we are here the data is valid and we can insert it into database ***/
    $phpro_username = filter_var($_POST['phpro_username'], FILTER_SANITIZE_STRING);
    $phpro_password = filter_var($_POST['phpro_password'], FILTER_SANITIZE_STRING);
    /*** now we can encrypt the password ***/
    $phpro_password = sha1( $phpro_password );
    /*** connect to database ***/
    /*** mysql hostname ***/
    $mysql_hostname = 'localhost';
    /*** mysql username ***/
    $mysql_username = ‘test_user’;
    /*** mysql password ***/
    $mysql_password = 'test';
    /*** database name ***/
    $mysql_dbname = ‘test;
    try
    {
        $dbh = new PDO("mysql:host=localhost;dbname=test", test, "test");
 /*** $message = a message saying we have connected ***/
        /*** set the error mode to excptions ***/
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        /*** prepare the insert ***/
        $stmt = $dbh->prepare('INSERT INTO phpro_users (phpro_username, phpro_password ) VALUES (:phpro_username, :phpro_password )');
        /*** bind the parameters ***/
        $stmt->bindParam(':phpro_username', $phpro_username, PDO::PARAM_STR);
        $stmt->bindParam(':phpro_password', $phpro_password, PDO::PARAM_STR, 40);
        /*** execute the prepared statement ***/
        $stmt->execute();
        /*** unset the form token session variable ***/
        unset( $_SESSION['form_token'] );
        /*** if all is done, say thanks ***/

header("Location: aconfirmation);
   catch(Exception $e)
    {
        /*** check if the username already exists ***/
        if( $e->getCode() == 23000)
        {
            $message = 'Username already exists';
        }
        else
        {
            /*** if we are here, something has gone wrong with the database ***/
            $message = 'We are unable to process your request. Please try again later';
        }
    }
}
?>
<html>
<head>
<title>Affiliate</title>
</head>
<body>
<p><?php echo $message; ?>
</body>
</html>

</div> <!-- end page-wrap -->
<?php get_footer(); ?>

主要问题:

while循环没有endwhile语句。将其添加到适当的位置

<?php endwhile;?>    // This goes where loop has to end

其他问题

1

header("Location: aconfirmation);

缺少"

header("Location: aconfirmation");

2

您没有try块的关闭}

这也会导致剩余的错误。但你知道什么好笑吗?我不需要浏览你所有的代码,我只是从SO语法高亮器那里得到了帮助,然后注意到了明显的错误,你也可以在提交问题之前使用它。

您缺少一个大括号和一个引号

    header("Location: aconfirmation"); // <-- HERE
} // <-- HERE
catch(Exception $e)
{