The Movie Database Support

i am new to api and i am having issues with the api requests
i am creating a streaming website and i searched for every movie in the TMDB i got the movie id and i added it into the database
so when the user clicks on one of the movie a script will get the movie id that matches the movie name in mysql (i dont know if this is the right way or not)
i only have movies in my website and only request these info title name - description - poster_path - category - runtime - year - imbdrating - actors with there posters.
everything works fine but sometimes my page give me Undefined variables for my requests and when i check my request log i fond that i am request random information not related to my requests like,
200 GET /3/tv/2 - 200 GET /3/search/multi - 200 GET /3/trending/all/day 7/28/2023 12:11 PM 200 GET /3/trending/all/day 7/28/2023 12:10 PM 200 GET /3/trending/all/day 7/28/2023 12:11 PM 200 GET /3/trending/all/day 7/28/2023 12:10 PM
simply a random requests so i dont know what to do hope i get help

code text here

// Fetch movie details from TMDB using the provided function
list($movieTitle, $movieDescription, $posterPath, $releaseYear, $runtime, $genres, $imdbRating) = getMovieDetails($MovieId, $apiKey);

function getMovieDetails($MovieId, $apiKey) {
    $baseUrl = "https://api.themoviedb.org/3/movie/{$MovieId}";
    $query = http_build_query([
        'api_key' => $apiKey,
        'append_to_response' => 'credits',
    ]);

    try {
        $httpClient = new \GuzzleHttp\Client();
        $response = $httpClient->get("$baseUrl?$query");

        $data = json_decode($response->getBody(), true);

        $movieTitle = $data['title'];
        $movieDescription = $data['overview'];
        $posterPath = $data['poster_path'];
        $releaseYear = date('Y', strtotime($data['release_date']));
        $runtime = $data['runtime'];
        $genres = array_column($data['genres'], 'name');
        $imdbRating = number_format($data['vote_average'], 1);


Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login