fatal error: uncaught error: call to undefined function mysql_connect_errno(), как исправить?
0
Fatal error: Uncaught Error: Call to undefined function mysql_connect_errno() in C:\xampp\htdocs\kinomonster\index.php:6 Stack trace: #0 C:\xampp\htdocs\kinomonster\index.php(42): insert(Object(SimpleXMLElement), Object(SimpleXMLElement), Object(SimpleXMLElement), NULL, Object(SimpleXMLElement), 1) #1 {main} thrown in C:\xampp\htdocs\kinomonster\index.php on line 6
Код
index.php
<?php
function insert($name, $desc, $year, $rating, $poster, $category_id){
$mysqli = new mysqli('localhost', 'root', '', 'kinomonster');
if (mysql_connect_errno()) {
print_r('Соединение не установлено');
exit();
}
$mysqli->set_charset('utf8');
$query = "INSERT INTO movie VALUES(null, '$name', '$desc', '$year', '$rating', '$poster', Now(), '$category_id')";
$result = false;
if ($mysqli->query($query)) {
$result = true;
}
return $result;
}
$xml = simplexml_load_file("xml_files/movies.xml") or die("error");
$title = null;
$title_origin = null;
$year = null;
$rating = null;
$post = null;
foreach ($xml as $movie_key => $movie) {
$title = $movie->title_russian;
$title_origin = $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'];
}else{
$rating = null;
}
insert($title, $title_origin, $year, $rating, $post, 1);
}
echo "<pre>";
print_r($xml);
echo "</pre>";
?>