![](/img/trans.png)
[英]Parse error: syntax error, unexpected end of file on line 150 (PHP Version to new?)
[英]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)
{
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.