每当我尝试添加新项目时,我都会收到此错误
解析错误:语法错误,第138行/web/stud/u1177827/add_boat.php中的意外$结尾
任何人都可以帮我解决吗?
在这里你这是我在php中的代码
<?php
$title="Register";
include("header.php");
?>
<div id="content_wrapper">
<table cellpadding="0" cellspacing="0" border="0" width="1000">
<tr>
<td valign="top">
</td>
<td valign="top">
<section id="main_content">
<?php
session_start();
if(!isset($_SESSION["staff"])){
header("location:staff_login.php");
exit();
if(isset($_POST['boatNo'])){
$boatNo = $_POST['boatNo'];
$boatNo = strip_tags($boatNo);
$location = $_POST['location'];
$location = strip_tags($location);
$type = $_POST['type'];
$type = strip_tags($type);
$cabins = $_POST['cabins'];
$cabins = strip_tags($cabins);
$rent = $_POST['rent'];
$rent = strip_tags($rent);
$ownerNo = $_POST['ownerNo'];
$ownerNo = strip_tags($ownerNo);
$staffNo = $_POST['staffNo'];
$staffNo = strip_tags($staffNo);
$branchNo = $_POST['branchNo'];
$branchNo = strip_tags($branchNo);
$results = $database->query("SELECT * FROM `BoatForRent` WHERE boatNo='$boatNo' LIKE '".$_GET['boatNo']."'");
$row = mysql_fetch_array($results);
if($row > 0)
{
echo '
<div class="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>boat id already exists!</strong> please choose another Boat ID
</div>
';
}
else
{
$done = mysql_query("INSERT INTO BoatForRent(boatNo, location, type, cabins, rent, ownerNo, staffNo, branchNo) VALUES ('$boatNo', '$location', '$type','$cabins','$rent','$ownerNo','$staffNo','$branchNo')");
if($done) {
echo '
<div class="alert alert-done">
A New Boat Have been Added Successful
</div>
';
}
else {
echo '
<div class="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>A New Boat Have been Added Unsuccessful! </strong> please try again
</div>
';
}
}
}
?>
<p><h2>Add new boat</h2></p>
<TABLE>
<FORM action="add_boat.php" method="post" enctype="multipart/form-data">
<TR>
<TD>Boat ID</TD><TD><INPUT type=TEXT name='boatNo'>
</TD>
</TR>
<TR><TD>Address</TD><TD><INPUT type=TEXT name='location'>
</TD>
</TR>
<TR>
<TD>Boat Type</TD><TD><INPUT type=TEXT name='type'>
</TD>
</TR>
<TR>
<TD>Number of Cabins</TD><TD><INPUT type=TEXT name='cabins'>
</TD>
</TR>
<tr>
<td>Rent</td>
<td><input type="text" name='rent' />
</td>
</tr>
<tr>
<td>Owner ID</td>
<td><input type=TEXT name='ownerNo' />
</td>
</tr>
<TR>
<TD>Staff ID</TD><TD><INPUT type=TEXT name='staffNo'>
</TD>
</TR>
<TR>
<TD>Branch ID</TD><TD><INPUT type=TEXT name='branchNo'>
</TD>
</TR>
<TR><TD><input type="submit" value="Submit" name="B1">
</TD>
<TD><input type="reset" value="Reset" name="B2">
</TD>
</TR>
</FORM>
</TABLE>
</section>
</td>
<td valign="top">
</td>
</tr>
</table>
</div>
</div>
<?php
include("footer.php");
?>
答案 0 :(得分:1)
你缺少这个条件的}
右括号
if(!isset($_SESSION["staff"])){
尝试根据您的要求关闭此项
if(!isset($_SESSION["staff"])){
header("location:staff_login.php");
exit();
}
以及你想要的地方
尝试检查isset()
或empty()
以避免通知
$boatNo = (!empty($_POST['boatNo']) ? $_POST['boatNo'] : '');
答案 1 :(得分:1)
问题是你错过了这个if块的右括号}
:
if(!isset($_SESSION["staff"])){
header("location:staff_login.php");
exit();
} // <-- this was missing
错误unexpected $end
表示解释器并不期望看到脚本的结束,因为它仍在等待结束括号。