phpoffice/phpspreadsheet libxml_disable_entity_loader() is deprecated

82 views Asked by At

i have a problem where the data from excel using phpoffice/phpspreadsheet been insert to database but it showing this error:

my data can insert but the problem is the error result.

here my coding:

<?php


include('../include/connection.php');
require '../vendor/autoload.php';
include('../include/session.php');
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;


    if (isset($_POST['save_excel_data'])) {
        $fileName = $_FILES['import_file']['name'];
        $file_ext = pathinfo($fileName, PATHINFO_EXTENSION);

        $allowed_ext = ['xls', 'csv', 'xlsx'];

        if (in_array($file_ext, $allowed_ext)) {
            $inputFileNamePath = $_FILES['import_file']['tmp_name'];
            $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileNamePath);
            $data = $spreadsheet->getActiveSheet()->toArray();

            $count = "0";
            foreach ($data as $row) {
                if ($count > 0) {
                    $UserLevel = $row['0'];
                    $NoIC = $row['1'];
                    $UEmail = $row['2'];
                    $FullName = $row['3'];

                    $studentQuery = "INSERT INTO users (UserLevel, NoIC, UEmail, FullName ,Password, UserStatus) VALUES ('$UserLevel', '$NoIC', '$UEmail', '$FullName' ,'$NoIC', 'Active')";
                    $result = mysqli_query($con, $studentQuery);
                    $msg = true;
                } else {
                    $count = "1";
                }
            }

            if (isset($msg)) {
                $_SESSION['message'] = "Successfully Imported";
                header('Location: index.php');
                exit(0);
            } else {
                $_SESSION['message'] = "Not Imported";
                header('Location: index.php');
                exit(0);
            }
        } else {
            $_SESSION['message'] = "Invalid File";
            header('Location: index.php');
            exit(0);
        }
    }

?>

Deprecated: Function libxml_disable_entity_loader() is deprecated in C:\laragon\www\mybookingtesting\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Reader\Security\XmlScanner.php on line 67

Warning: Trying to access array offset on value of type null in C:\laragon\www\mybookingtesting\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Reader\Xlsx\Styles.php on line 133

so can you guys help me and tell me where the problem.

if possible can i just redirect and ignore the error?

i already use chatgpt but it cannot be fix.

0

There are 0 answers