Problem solved: Turns out my $video variable was an empty array instead of a empty string.
{{ $video \}} //Without the '\'
The code above throw the exception.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello guys! I am building a website using the php-tmdb/laravel framework.
I have a controller for handling movies: (I know it is messy, but the site is in developement...)
public function show($id)
{
$nextMovie = Tmdb::getMoviesApi()->getRandomMovie(['vote_count.gte' => 20, 'release_date.lte' => '2015-08-30', 'release_date.gte' => '2000-01-01']);
$movie = Tmdb::getMoviesApi()->getMovie($id, ['language' => 'en']);
$backdrops = Tmdb::getMoviesApi()->getImages($movie['id'])['backdrops'];
$video = Tmdb::getMoviesApi()->getVideos($movie['id'])['results'];
if (count($video) > 0){
$video = $video[0]['key'];
}
$jsonurl = "https://yts.to/api/v2/list_movies.json?query_term=" . $movie['imdb_id'];
$response = json_decode(file_get_contents($jsonurl));
if ($response->data->movie_count == 1){
$jsonurl = 'https://yts.to/api/v2/movie_reviews.json?movie_id=' . $response->data->movies[0]->id;
$torrents = $response->data->movies[0]->torrents;
$response = json_decode(file_get_contents($jsonurl));
$reviews = $response->data->reviews;
} else {
$torrents = null;
$reviews = null;
}
return view('movie', compact('movie', 'backdrops', 'video', 'nextMovie'));
}
The error msg: (not for every movie)
ErrorException in helpers.php line 454: htmlentities() expects parameter 1 to be string, array given.
Some movies does not want to show up... The error is with the movie variable, but I have no idea what is the problem. (If I remove it from the compact function the view loads.)
Here is the movie variable: (This wont load..)
{
"adult": false,
"backdrop_path": "/3mAMaxmEuNFW6Rm9f90wfZgGUvL.jpg",
"belongs_to_collection": null,
"budget": 0,
"genres": [
{
"id": 28,
"name": "Action"
},
{
"id": 18,
"name": "Drama"
}
],
"homepage": "",
"id": 9787,
"imdb_id": "tt0355702",
"original_language": "en",
"original_title": "Lords of Dogtown",
"overview": "The film follows the surf and skateboarding trends that originated in Venice, California during the 1970's.",
"popularity": 0.422658,
"poster_path": "/k1WjRObfqZV7EfmhsnUmhx88EAa.jpg",
"production_companies": [
{
"name": "Columbia Pictures",
"id": 5
},
{
"name": "TriStar Pictures",
"id": 559
}
],
"production_countries": [
{
"iso_3166_1": "DE",
"name": "Germany"
},
{
"iso_3166_1": "US",
"name": "United States of America"
}
],
"release_date": "2005-06-03",
"revenue": 0,
"runtime": 107,
"spoken_languages": [
{
"iso_639_1": "hu",
"name": "Magyar"
},
{
"iso_639_1": "es",
"name": "Español"
},
{
"iso_639_1": "en",
"name": "English"
}
],
"status": "Released",
"tagline": "They never thought they'd be famous, but they always thought they'd be friends.",
"title": "Lords of Dogtown",
"video": false,
"vote_average": 6.7,
"vote_count": 58
}
And here is one wich loads:
{
"adult": false,
"backdrop_path": "/hUDEHvhNJLNcb83Pp7xnFn0Wj09.jpg",
"belongs_to_collection": null,
"budget": 18000000,
"genres": [
{
"id": 18,
"name": "Drama"
},
{
"id": 35,
"name": "Comedy"
}
],
"homepage": "",
"id": 194662,
"imdb_id": "tt2562232",
"original_language": "en",
"original_title": "Birdman",
"overview": "A fading actor best known for his portrayal of a popular superhero attempts to mount a comeback by appearing in a Broadway play. As opening night approaches, his attempts to become more altruistic, rebuild his career, and reconnect with friends and family prove more difficult than expected.",
"popularity": 9.548755,
"poster_path": "/rSZs93P0LLxqlVEbI001UKoeCQC.jpg",
"production_companies": [
{
"name": "Worldview Entertainment",
"id": 9015
},
{
"name": "New Regency Pictures",
"id": 10104
},
{
"name": "TSG Entertainment",
"id": 22213
},
{
"name": "Le Grisbi Productions",
"id": 47169
},
{
"name": "M Productions",
"id": 52660
}
],
"production_countries": [
{
"iso_3166_1": "US",
"name": "United States of America"
}
],
"release_date": "2014-10-17",
"revenue": 103215094,
"runtime": 119,
"spoken_languages": [
{
"iso_639_1": "en",
"name": "English"
}
],
"status": "Released",
"tagline": "or (The Unexpected Virtue of Ignorance)",
"title": "Birdman",
"video": false,
"vote_average": 7.4,
"vote_count": 1358
}
Any ideas?
Problem solved: Turns out my $video variable was an empty array instead of a empty string.
{{ $video \}} //Without the '\'
The code above throw the exception.
Please or to participate in this conversation.