Не добавляется запись из xml в бд. что делаю неправильно?
0
<?php
function insert($name, $desc, $year, $rating, $poster, $category_id){
$mysqli = new mysqli('localhost', 'root', '', 'kinomonster');
if (mysqli_connect_errno()) {
print_f('Соединение не установлено');
exit();
}
$mysqli->set_charset(utf8);
$query = "INSERT into movie VALUES(null, '$name', '$desc', '$year', '$rating', '$poster', Now(), '$category_id')";
$xml = simplexml_load_file("xml/movies.xml") or die("Error: Cannot creat object");
$result = false;
if ($mysqli->query($query)) {
$result = true;
}
return $result;
}
$xml = simplexml_load_file("xml/movies.xml") or die("Error: Cannot creat obj```ect");
# echo count($xml);
$title = null;
$title_orign = null;
$post = null;
$rating = null;
$year = null;
foreach($xml as $movie_key => $movie) {
$title = $movie->title_russian;
$title_orign = $movie->title_original;
$year = $movie->year;
foreach ($movie->poster->big->attributes() as $poster_key => $poster){
$post = $poster;
}
if ($movie->imdb) {
$rating = $movie->imdb->attributes()['rating'];
}
insert($title, $title_orign, $year, $rating, $post, 1);
}
echo "<pre>";
print_r($xml);
echo "</pre>";
?>
что делаю неправильно?