I am having a problem in my code
<?php
$con=mysqli_connect("localhost","test","test","test");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"select movie_name from jos_movie");
while ($row = mysqli_fetch_array($result)){
$movie_name= $row['movie_name'];
$xmls = simplexml_load_file("http://api.themoviedb.org/2.1/Movie.search/en/xml/myapi/$movie_name");
foreach($xmls->movies->movie as $movies){
$arrMovie_id= $movies->id;
}
echo $arrMovie_id;
}
?>
If you see I am passing URL to fetch the results for movie ID . When the movie is of single name for example "Ironman" it fetches the correct movie Id "10505" and if the movie name is "Ironman 2' it wont work and gives wrong ID. But if I pass movie_name as "ironman%202" it fetches the correct result . How can I get the space problem fix . Since from DB it fetchs "ironman 2"
I have tried
while ($row = mysqli_fetch_array($result)){
$movie_name= urlencode($row['movie_name']);
$xmls = simplexml_load_file('http://api.themoviedb.org/2.1/Movie.search/en/xml/myapi/'.$movie_name);
and
while ($row = mysqli_fetch_array($result)){
$movie_name= rawurlencode($row['movie_name']);
$xmls = simplexml_load_file('http://api.themoviedb.org/2.1/Movie.search/en/xml/myapi/'.$movie_name);
its not working :(
Thanks