簡體   English   中英

解析錯誤:語法錯誤,第122行中的文件意外結束

[英]Parse error: syntax error, unexpected end of file in on line 122

***>有人在php中遇到此問題,請hlpe me pleaz這個錯誤使我抓狂這里是代碼*

    <?php
if ($_POST["submit"]) {
if (!$_POST['name']) {
$error="<br />Please enter your name";
}
if (!$_POST['email']) {
$error.="<br />Please enter your email address";
}
if (!$_POST['comment']) {
$error.="<br />Please enter a comment";
}



if ($error) {
$result='<div class="alert alert-danger"><strong>There were error(s)
in your form:</strong>'.$error.'</div>';
}

?>

<!doctype html>
<html>
<head>
<title>My First Webpage</title>
!
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
!
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/
bootstrap.min.css">
!
<!-- Optional theme -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/
bootstrap-theme.min.css">
!
<style>
!
.emailForm {
border:1px solid grey;
border-radius:10px;
margin-top:20px;
}
!
form {
padding-bottom:20px;
}
!
</style>
!
</head>
!
<body>
!
!
!
!
!
<div class="container">
!
<div class="row">
!
<div class="col-md-6 col-md-offset-3 emailForm">
<h1>My email form</h1>
!
!
<p class="lead">Please get in touch - I'll get back to you as soon as I can.</p>
!
<form method="post">
!
<div class="form-group">
!
<label for="name">Your Name:</label>
<input type="text" name="name" class="form-control" placeholder="Your Name"/>

!
</div>
!
<div class="form-group">
!
<label for="email">Your Email:</label>
<input type="email" name="email" class="form-control" placeholder="Your Email"/>

 !
</div>
!
<div class="form-group">
!
<label for="comment">Your Comment:</label>
<textarea class="form-control" name="comment"></textarea>

!
</div>
!
<input type="submit" name="submit" class="btn btn-success btn-lg" value="Submit"/>

!
!
</form>
!
</div>
!
</div>
!
</div>

<!-- Latest compiled and minified JavaScript -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>


</body>
</html>

有人用php的這個問題讓我煩惱文件的末尾此錯誤使我發瘋這里是代碼*

第一個if中的“ {”永遠不會關閉。

您缺少括號。 嘗試這個:

<?php
if ( isset( $_POST["submit"] ) ) {
    if (!$_POST['name']) {
    $error="<br />Please enter your name";
    }
    if (!$_POST['email']) {
    $error.="<br />Please enter your email address";
    }
    if (!$_POST['comment']) {
    $error.="<br />Please enter a comment";
    }



    if ($error) {
    $result='<div class="alert alert-danger"><strong>There were error(s)
    in your form:</strong>'.$error.'</div>';
    }
}
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM