I am trying to update a SQL table using data from an HTML form but am getting the following error:
This is how I handle the POST request for my Form:
$con = mysqli_connect("localhost", "root", "", "lectureHub");
if (isset($_POST['rating'])) {
$likert = $_POST['likert'];
$feedback = $_POST['feedback'];
$chapter_id_fk = $_POST['chapter_id_fk'];
$page_id_fk = $_POST['page_id_fk'];
//echo "Entered data successfully. Click on LectureHub tab to see the Lecture";
$sql = "UPDATE pages SET likert = $likert, feedback = $feedback WHERE chapter_id_fk = $chapter_id_fk and page_id = $page_id_fk";
$retval = mysqli_query($con, $sql);
if (!$retval) {
die('Could not enter data: ' . mysqli_error());
}
$sql_page_id ="select page_id_fk from pages where chapter_id_fk = $chapter_id_fk and page_id = $page_id_fk ";
$result = mysqli_query($con,$sql_page_id);
if ($result->num_rows>0){
while($row = $result->fetch_assoc()){
$page_id_fk = $row['page_id_fk'];
echo "<script> window.location = 'index.php?action=lec_hub/pages&page_id=$page_id_fk&chapter_id=$chapter_id_fk'; </script>";
}
}
//echo "<script> window.location = 'index.php?action=lec_hub/pages&page_id=$sql_page_id&chapter_id=$chapter_id_fk'; </script>";
}
Could someone explain me why am I getting the error and how can I resolve it?
