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

时间:2013-11-30 04:20:59

标签: php wordpress parsing syntax

我一直想要永远解决这个问题。我已经看过每一个地方,无法解决这个问题。我不是那么好的编码器,所以我真的不知道出了什么问题。我问过几个人,他们帮助我解决了其他错误,然后就出现了,他们无能为力。错误后出现错误,请帮忙。这是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(); ?>

2 个答案:

答案 0 :(得分:0)

主要问题:

你的while循环没有endwhile语句。将其添加到适当的地方

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

其他问题

<强> 1

header("Location: aconfirmation);

缺少"

header("Location: aconfirmation");

<强> 2

}

没有结束try

<击> 这会导致剩余的错误太多。但你知道什么是有趣的吗?我没有必要通过你的所有代码,我只是从SO语法荧光笔获得帮助,然后注意到显然是错误的,你也可以在提交问题之前将它用于你的利益。

答案 1 :(得分:0)

您缺少大括号和引号

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