Php 解析错误:语法错误,第150行代码中的意外文件结尾错误解析代码
我一直在想办法解决这个问题。我到处都找过了,不能解决这个问题。我不是一个出色的程序员,所以我真的不知道出了什么问题。我问过几个人,他们帮我解决了其他的错误,然后这个问题出现了,他们帮不上忙。这是一个又一个错误,请帮助。这是wordpress,只是想帮点忙Php 解析错误:语法错误,第150行代码中的意外文件结尾错误解析代码,php,wordpress,parsing,syntax,Php,Wordpress,Parsing,Syntax,我一直在想办法解决这个问题。我到处都找过了,不能解决这个问题。我不是一个出色的程序员,所以我真的不知道出了什么问题。我问过几个人,他们帮我解决了其他的错误,然后这个问题出现了,他们帮不上忙。这是一个又一个错误,请帮助。这是wordpress,只是想帮点忙 <?php session_start(); ?> <?php /* Template Name: test */ ?> <?php get_header(); ?> <?php get_t
<?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
缺少一个“
2
对于try
块,您没有关闭}
这也会导致剩下的错误。但是你知道什么很有趣吗?我不必看你所有的代码,我只是从SO syntax highlighter那里得到了帮助,然后注意到了明显的错误,你也可以在提交问题之前使用它。
缺少一个大括号和引号
header("Location: aconfirmation"); // <-- HERE
} // <-- HERE
catch(Exception $e)
{
标题(“位置:确认”);//是的,我知道,这是我在编辑代码以编辑我的信息时偶然发生的。这不是我的问题,但谢谢。有趣的是我做了语法高亮显示。引号不是我的问题,我在编辑我的信息时意外地编辑了它。引号在那里,这并没有解决问题。谢谢你的帮助尽管如此。如果您知道如何解决我当前的问题,请提供帮助。虽然我们只能根据提供的信息进行回答,因此错误的编辑也可能会导致错误的答案,因此我们必须特别注意在提问时正确复制我们的问题。尽管如此,请查看更新的答案,您将得到您想要的答案我在找。Cheers@hanky-panky我这样做了,它给了我一个错误解析错误:语法错误,第135行代码中意外的“}”错误解析代码,我删除了这个错误,然后返回到页脚错误。知道吗?你把它放在哪里了?就在页眉调用之后?你介意解释一下我应该把它放在哪里吗?我还在学习php和如果您不介意的话,我将非常感谢您的帮助,以便我知道在将来的参考中应该把它放在哪里,就像上面显示的endwhile语句一样。
header("Location: aconfirmation");
header("Location: aconfirmation"); // <-- HERE
} // <-- HERE
catch(Exception $e)
{