0

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"); ?> 
3
  • check your footer.php and header.php too Commented Dec 2, 2015 at 5:21
  • My header and footer files work just fine with all of my other pages. It was all working fine until I decided to change my code to try and prevent sql injection. I did just double check though and yeah, they're fine Commented Dec 2, 2015 at 5:24
  • check you bind_param your need bind_param you need equal number of ss and i tha parameter you bind Commented Dec 2, 2015 at 5:27

1 Answer 1

1

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']?>"

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.