javascript – can someone please explain these errors?

I can’t understand why these bugs are coming or where the bug is and how to fix it. This is the first time I’m working with backend, so understand 🙂 My first page is a login page with a search bar. As soon as I click on the search button, I get it.

Mistake

<?php
session_start();
require "includes/database_connect.php";

$mem_id = isset($_SESSION['mem_id']) ? $_SESSION['mem_id'] : NULL;
$book_name = $_GET["book_name"];

$sql_1 = "SELECT * FROM stock WHERE name="$book_name"";
$result_1 = mysqli_query($conn, $sql_1);
if (!$result_1) {
    echo "Something went wrong!";
    return;
}
$city = mysqli_fetch_assoc($result_1);
if (!$city) {
    echo "Sorry! We do not have this book.";
    return;
}
$book_id = $stock['book_id'];


$sql_2 = "SELECT * FROM stock WHERE book_id = $book_id";
$result_2 = mysqli_query($conn, $sql_2);
if (!$result_2) {
    echo "Something went wrong!";
    return;
}
$properties = mysqli_fetch_all($result_2, MYSQLI_ASSOC);

$sql_3 = "SELECT * 
            FROM borrowed_books iup
            INNER JOIN stock p ON iup.book_id = p.book_id
            WHERE p.book_id = $book_id";
$result_3 = mysqli_query($conn, $sql_3);
if (!$result_3) {
    echo "Something went wrong!";
    return;
}
$interested_users_properties = mysqli_fetch_all($result_3, MYSQLI_ASSOC);
?>

This is my booklist.php code. I have removed the html part for easy understanding.

Write a Comment

Your email address will not be published. Required fields are marked *