I am trying to debug an issue in php. Essentially, the code is trying to add a movie review by a user into a database. if it already exists, it simply updates.
When the mysqli_stmt_execute($query) is run, for some reason, code inside the sql statements in the if statements return false for some reason.
I determined for sure that the error lies within the mysqli_stmt_execute, although I have no idea why.
Does anyone have any ideas what could be causing this error.
public function insertRatings($movieName, $username, $rating, $major, $comment) {
$json = array();
$connection = $this->db->getDb();
$query = mysqli_prepare($connection, "INSERT INTO " . $this->db_table . " (movie, username, rating, major, comment) VALUES ('$movieName', '$username', '$rating', '$major', '$comment')");
$firstBool = mysqli_stmt_execute($query);
$query2 = mysqli_prepare($connection, "SELECT * FROM " . $this->db_table2 . " WHERE movie = '$movieName' AND major = '$major'");
$query3 = mysqli_prepare($connection, "INSERT INTO recommendations (major, movie, rating, numratings) VALUES ('$major', '$movieName', '$rating', 1)");
$secondBool = mysqli_stmt_execute($query3);
mysqli_stmt_execute($query2);
if (mysqli_stmt_num_rows($query2) == 0) {
$query3 = mysqli_prepare($connection, "INSERT INTO recommendations (major, movie, rating, numratings) VALUES ('$major', '$movieName', '$rating', 1)");
$secondBool = mysqli_stmt_execute($query3);
}