doupi7619 2015-12-02 05:19
浏览 50
已采纳

解析错误,意外的文件结束 - 无法找出问题所在

Here is my page so far. I know it's a lot, so please bear with me.

It said that my issue occurred on line 80, which is the bottom of my file, a couple of spaces after the last closing tag. I'm unsure of what could be wrong, I've been looking for a good while now. :(

<?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>&nbsp;&nbsp;&nbsp;

                    <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>&nbsp;&nbsp;&nbsp;

                    <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>&nbsp;&nbsp;&nbsp;

                    <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"); 
?>
  • 写回答

1条回答 默认 最新

  • douquan1015 2015-12-02 05:27
    关注

    This line may be the culprit

    <input type="hidden" name="lastEditor" value="<?php echo $_SESSION["User"]?>">
    

    You're using double quotes in unexpected way for "<?php echo $_SESSION["User"]?>"

    Make it "<?php echo $_SESSION['User']?>"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?