到目前为止,这是我的页面。我知道很多,所以请耐心等待。
它说我的问题发生在第80行,这是我文件的底部,在最后一个结束标记之后的几个空格。我不确定可能出现什么问题,我现在一直在寻找一段时间。 :(
<?php
$title="Events";
require("header.php");
?>
<div class="editEvent">
<?php
if(isset($_SESSION["User"])) {
//Server info goes here*
// create connection
$mysqli = new mysqli($servername, $username, $password, $db);
// check connection
if($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
if (isset($_POST["lastEditor"])){
$eventId = $_POST['editEvent'];
$name = $_POST['eventName'];
$date = $_POST['eventDate'];
$start = $_POST['startTime'];
$end = $_POST['endTime'];
$location = $_POST['location'];
$about = $_POST['about'];
$contactName = $_POST['contactName'];
$contactNo = $_POST['contactNo'];
$contactEmail = $_POST['contactEmail'];
$lastEditor = $_POST["lastEditor"];
if($stmt = $mysqli->prepare("UPDATE Events SET Name =?, Date = ? , StartTime = ?, EndTime = ?, Location = ?, ContactName = ?, ContactNo = ?, ContactEmail = ?, LastEditor = ?, About = ?, LastEdit = ? WHERE id = ?")){
$stmt->bind_param("ss", $name, $date, $startTime, $endTime, $location, $contactName, $contactNo, $contactEmail, $lastEditor, $about, $eventId);
$stmt->execute();
$stmt->close();
echo("Thank you. Your event has been updated");
}
else {
echo "Error: " . $stmt->error;
}
}
$event = $_POST['editEvent'];
if($stmt = $mysqli->prepare("SELECT * FROM Events WHERE id =?")){
$stmt->bind_param("ss", $name, $date, $startTime, $endTime, $location, $contactName, $contactNo, $contactEmail, $lastEditor, $about, $eventId);
$stmt->execute();
$stmt->bind_result( $name, $date, $startTime, $endTime, $location, $contactName, $contactNo, $contactEmail, $lastEditor, $about, $eventId);
while($stmt->fetch()){ ?>
<form method='post' action='editEvent.php' onsubmit='return validateEvent()' id='editEventForm'>
<input type="hidden" name="editEvent" value="<?php echo $eventId; ?>">
<input type="text" name="eventName" maxlength="255" value="<?php echo $name; ?>" required><br/><br/>
<input type="date" name="eventDate" maxlength="10" value="<?php echo $date; ?>" required>
<input type="time" name="startTime" maxlength="10" value="<?php echo $start; ?>" required>
<br/><br/>
<input type="time" name="endTime" maxlength="10" value="<?php echo $end; ?>" required>
<input type="text" name="location" maxlength="80" value="<?php echo $location; ?>" required>
<br/><br/>
<input type="text" name="contactName" maxlength="30" value="<?php echo $contactName; ?>" required>
<input type="tel" name="contactNo" maxlength="13" value="<?php echo $contactNo; ?>" required>
<input type="email" name="contactEmail" maxlength="255" value="<?php echo $contactEmail; ?>" required>
<br/><br/>
<input type="hidden" name="lastEditor" value="<?php echo $_SESSION["User"]?>">
<textarea rows="4" cols="50" name="about" form="editEventForm"><?php echo $about; ?></textarea>
<input type="submit">
</form><?php
}$stmt->close();
}
$mysqli->close();
}
?>
</div>
<?php
require("footer.php");
?>
答案 0 :(得分:1)
这一行可能是罪魁祸首
<input type="hidden" name="lastEditor" value="<?php echo $_SESSION["User"]?>">
您以"<?php echo $_SESSION["User"]?>"
将其设为"<?php echo $_SESSION['User']?>"