Its keeps on saying Parse error: syntax error, unexpected end of file in D:xampphtdocsFinalWeb2posting.php on line 111

  php, session

So I have a problem with this maybe its because of the session so how can I fix it?
And It keeps on saying

Parse error: syntax error, unexpected end of file in D:xampphtdocsFinalWeb2posting.php on line 111

Code:

<?php 
session_start();


if (isset($_SESSION['id']) && isset($_SESSION['username']) && isset($_SESSION['img'])) {
    $sender = $_SESSION['username'];
    $post = $_POST['txt'];
    $submit = $_POST['submit'];
    $host = "localhost";
    $user = "root";
    $pass = "";
    $dbName = "posts";
    $id = $_SESSION['id'];
    $img = $_SESSION['img'];

    $conne = new mysqli($host, $user, $pass, $dbName);
    // Check connection
    if ($conne->connect_error) {
      die("Connection failed: " . $conne->connect_error);
    }

    if (isset($submit)) {
      $target_dir = "attatch/";
      $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
      $uploadOk = 1;
      $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

      $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
      if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
      } else {
        echo "File is not an image.";
        $uploadOk = 0;
      }

              // Check if file already exists
        if (file_exists($target_file)) {
          echo "Sorry, file already exists.";
          $uploadOk = 0;
        }

        // Check file size
        if ($_FILES["fileToUpload"]["size"] > 100000000) {
          echo "Sorry, your file is too large.";
          $uploadOk = 0;
        }

        // Allow certain file formats
        if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
        && $imageFileType != "gif" && $imageFileType != "tiff") {
          echo "Sorry, only JPG, JPEG, PNG, TIFF & GIF files are allowed.";
          $uploadOk = 0;
        }

        // Check if $uploadOk is set to 0 by an error
        if ($uploadOk == 0) {
          echo "Sorry, your file was not uploaded.";
        // if everything is ok, try to upload file
        } else {
          $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
          $random = substr(str_shuffle($permitted_chars), 0, 25);
          $newfilename = $sender.".".$random.".".$imageFileType;
          if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "attatch/" . $newfilename)) {
            
          } else {
            echo "Sorry, there was an error uploading your file.";
          }
        }

        $includeVariable = include('get_comment.php');

      $insert = 
      '</div>
      <br><br><br>
      <div class="posts-container">
        <img src="'.$img.'" class="profpic"/>
        <div class="editB-cont">
          <img src="img/editB.png" class="editB"/>
        </div>
          <h1>'.$sender.'</h1>
        <hr class="solid">
        <p class="post-text-container">'.$post.'</p>
        <br><br>
        <img src="'."attatch/".$newfilename.'" class="attach"/>
        <br><br>
        <form action="post-comment" method="post">
          <input type="hidden" name="parent-id" value="<?php echo $postId; ?>">
          <input type="text" name="comment-text" placeholder="Comment...">
          <input type="submit" value="Post" name="submit">
        </form>
        <br>
        <div class="coments">' . $includeVariable . '</div><br>
    </div><br><br>
    ';
    $sql = "INSERT INTO posts (sender, post, sender_id, image_attach, sender_img) VALUES ('$sender', '$insert', $id, 'attatch/$newfilename', '$img')";

    if ($conne->query($sql) === TRUE) {
      echo "New record created successfully";
    } else {
      echo "Error: " . $sql . "<br>" . $conne->error;
    }

?>
<?php
}else{
     header("Location: index");
     exit();
     $conn->close();
}
?>

This is website is for uploading posts then fetching it
I hope you can help me because I am really stuck here

Source: Ask PHP

LEAVE A COMMENT