我是php的新手。我有一个注册页面,其中包含一些用户详细信息并创建一个帐户。在运行代码时出现此错误:
Parse error: syntax error, unexpected end of file on line 347
我看过很少其他与同一问题相关的帖子,但我没有发现任何对我的代码有帮助的帖子。我已多次查看代码,看看我做错了什么但找不到我的错误。请帮助我说错了。提前谢谢。
我的代码如下:
登录-up.php
<!DOCTYPE html>
<html>
<head>
<title>My Trip Planner | Sign Up </title>
<!-- for-mobile-apps -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Xtreme Travel Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- //for-mobile-apps -->
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/styles.css?v=1.6" rel="stylesheet">
<!-- js -->
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/scripts.js?v=1.7"></script>
<!-- //js -->
<!-- start-smoth-scrolling -->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
});
});
</script>
<script type="text/javascript">
function formValidation()
{
var uid = document.registration.userid;
var passid = document.registration.passid;
var uemail = document.registration.email;
if(userid_validation(uid,5,12))
{
if(passid_validation(passid,7,12))
{
if(ValidateEmail(uemail))
{
}
}
}
return false;
}
function userid_validation(uid,mx,my)
{
var uid_len = uid.value.length;
if (uid_len == 0 || uid_len >= my || uid_len < mx)
{
alert("User Id should not be empty / length be between "+mx+" to "+my);
uid.focus();
return false;
}
return true;
}
function passid_validation(passid,mx,my)
{
var passid_len = passid.value.length;
if (passid_len == 0 ||passid_len >= my || passid_len < mx)
{
alert("Password should not be empty / length be between "+mx+" to "+my);
passid.focus();
return false;
}
return true;
}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
//alert("You have entered a valid email address!");
return true;
}
else
{
alert("You have entered an invalid email address!");
uemail.focus();
return false;
}
}
</script>
<!-- start-smoth-scrolling -->
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Comfortaa:400,300,700' rel='stylesheet' type='text/css'>
</head>
<?php
session_start();
if(!empty($_POST)) {
class MyDB extends SQLite3
{
function __construct()
{
$this->open('mytrip.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
}
$id=null;
$pass=null;
$email=null;
$fname=null;
$lname=null;
$id_exists=false;
if (isset($_POST['uid'])) {
$id = $_POST['uid'];
}
if (isset($_POST['passid'])) {
$pass = $_POST['passid'];
}
if (isset($_POST['uemail'])) {
$email = $_POST['uemail'];
}
if (isset($_POST['first'])) {
$fname = $_POST['first'];
}
if (isset($_POST['last'])) {
$lname = $_POST['last'];
$result= "SELECT COUNT(*) FROM Users WHERE ID = '".$id. "';" ;
$count= $db->querySingle($result);
if ($count > 0)
{
$id_exists = true;
echo "This id is not available. Please enter a valid id. ";
}
else
{
$sql= " INSERT INTO Users (ID, PASSWORD, EMAIL, FNAME, LNAME)
VALUES ('$id','$pass','$email', '$fname', '$lname'); " ;
$ret = $db->query($sql);
$_SESSION['Id'] = $id;
header("location:index.php");
}
$db->close();
}
?>
<body>
<!-- banner -->
<div class="banner1">
<div class="navigation">
<div class="container-fluid">
<nav class="pull">
<ul class="nav">
<li><a href="index.php" class="active"> Home</a></li>
<li><a href="index.php"> About</a></li>
<li><a href="index.php" class="menu">Popular Places<span class="glyphicon glyphicon-menu-down" aria-hidden="true"></span></a></li>
<ul class="nav-sub">
<li><a href="index.php">Place 1</a></li>
<li><a href="index.php">Place 2</a></li>
<li><a href="index.php">Place 3</a></li>
</ul>
<script>
$( "li a.menu" ).click(function() {
$( "ul.nav-sub" ).slideToggle( 300, function() {
// Animation complete.
});
});
</script>
<li><a href="index.php"> Events</a></li>
<li><a href="index.php"> Mail us</a></li>
</ul>
</nav>
</div>
</div>
<div class="header-top">
<div class="container">
<div class="head-logo">
<a href="index.php"><span>M</span>y Trip Planner<i>Feeling Amazing Tour</i></a>
</div>
<div class="top-nav">
<div class="hero fa-navicon fa-2x nav_slide_button" id="hero">
<a href="#"><img src="images/menu.png" alt=""></a>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
<!-- banner -->
<!-- sign-in -->
<div class="sign-in">
<div class="container">
<div class="in-form">
<h3>Register Here</h3>
<p class="use">Having hands on experience in creating innovative
designs,I do offer design solutions which harness.</p>
<div class="sign-in-form">
<div class="in-form Personal">
<h4>Personal Information</h4>
<form method="post" name='registration' onSubmit="return formValidation();">
<input type="text" placeholder="Firstname*" required=" " name="first">
<input type="text" placeholder="Lastname*" required=" " name="last">
<input type="text" placeholder="Emailaddress*" required=" " name="uemail">
<h4 class="kij">Login Information</h4>
<input type="text" placeholder="Id*" required=" " name="uid">
<input type="password" placeholder="Password*" required=" " name="passid">
<input type="password" placeholder="Confirm Password*" required=" ">
<input type="submit" value="submit">
</form>
</div>
</div>
</div>
</div>
</div>
<!-- //sign-in -->
<!-- footer-top -->
<div class="footer-top">
<div class="container">
<div class="col-md-3 footer-top-grid">
<h3>About <span> My Trip Planner</span></h3>
<p>Lets you plan the finest trips.</p>
</div>
<div class="col-md-3 footer-top-grid">
<h3>THE <span>TAGS</span></h3>
<div class="unorder">
<ul class="tag2">
<li><a href="#">pool</a></li>
<li><a href="#">gym</a></li>
<li><a href="#">beach</a></li>
</ul>
<ul class="tag2">
<li><a href="#">asian</a></li>
<li><a href="#">thai</a></li>
<li><a href="#">chinese</a></li>
<li><a href="#">american</a></li>
</ul>
<ul class="tag2">
<li><a href="#">theme park</a></li>
<li><a href="#">wildlife</a></li>
<li><a href="#">heritage</a></li>
</ul>
<ul class="tag2">
<li><a href="#">shopping malls</a></li>
<li><a href="#">local shops</a></li>
<li><a href="#">boutiques</a></li>
</ul>
</div>
</div>
<div class="col-md-3 footer-top-grid">
<h3> User <span> Reviews</span></h3>
<ul class="twi">
<li>Location is close to empire state building and near bus stop. Staff was pleasant on check in.
<span></span></li>
<li>Outstanding food and service. Would return without hesitation.
<span></span></li>
<li>My wife and I love walking around and exploring cities. and New York is one of the few cities in USA you can enjoy doing that. SoHo has a great vibe about it, and we enjoyed walking around, grabbing a quick bite, and doing some shopping.
<span></span></li>
</ul>
</div>
<div class="col-md-3 footer-top-grid">
<h3> Popular <span> Destinations</span></h3>
<div class="flickr-grids">
<div class="flickr-grid">
<a href="#"><img src="images/minar.jpg" alt=" " class="img-responsive" /></a>
</div>
<div class="flickr-grid">
<a href="#"><img src="images/bad.jpg" alt=" " class="img-responsive" /></a>
</div>
<div class="flickr-grid">
<a href="#"><img src="images/kua1.jpg" alt=" " class="img-responsive" /></a>
</div>
<div class="clearfix"> </div>
<div class="flickr-grid">
<a href="#"><img src="images/kua.jpg" alt=" " class="img-responsive" /></a>
</div>
<div class="flickr-grid">
<a href="#"><img src="images/newyork.jpg" alt=" " class="img-responsive" /></a>
</div>
<div class="flickr-grid">
<a href="#"><img src="images/can1.jpg" alt=" " class="img-responsive" /></a>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- //footer-top -->
<!-- footer -->
<div class="footer">
<div class="container">
<div class="footer-left">
<ul>
<li><a href="index.php"><i>M</i>y Trip Planner</a><span> |</span></li>
<!-- <li><p>The awesome agency. <span>0800 (123) 4567 // Australia 746 PO</span></p></li> -->
</ul>
</div>
<div class="footer-right">
<p>© 2017 My Trip Planner. All rights reserved | </p>
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- //footer -->
<!-- here stars scrolling icon -->
<script type="text/javascript">
$(document).ready(function() {
/*
var defaults = {
containerID: 'toTop', // fading element id
containerHoverID: 'toTopHover', // fading element hover id
scrollSpeed: 1200,
easingType: 'linear'
};
*/
$().UItoTop({ easingType: 'easeOutQuart' });
});
</script>
<!-- //here ends scrolling icon -->
</body>
</html>
答案 0 :(得分:0)
在第141行添加一个右括号,代码为:
if (isset($_POST['last'])) {
$lname = $_POST['last'];
}
我在本地测试了你的代码,这就解决了语法错误。
答案 1 :(得分:0)
你有这个错误,因为你错过了&#34;}&#34;在第141行:
if (isset($_POST['last'])) {
$lname = $_POST['last'];
答案 2 :(得分:0)
您使用什么IDE或文本编辑器编写代码?我会建议你指出这样简单的错误。例如netbeans for php或php storm,netbeans是免费的,php风暴不是。这两位编辑都会向你展示你的错误。