简体   繁体   中英

load data infile in php not work

i try to make upload menu in php using load data infile cause the file that i need to upload is so large

this is the code

<html>
<head>
</head>
<body>
    <?php
    include ("Connections/connection.php");
    if (isset($_POST["importodp"])) {
        if (!empty($_FILES["excelFile"]["tmp_name"])) {
            $filename = explode(".", $_FILES["excelFile"]["name"]);
            if ($filename[1] == "csv") {

                $file = addslashes($_FILES['excelFile']['tmp_name']);
                echo $file;

                mysqli_select_db($config, $database_config);
                $input_odp = "LOAD DATA LOCAL INFILE '$file' INTO TABLE `odp_report` FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'";
                $run_input_odp = mysqli_query($config, $input_odp) or die(mysqli_error());

                if (!$run_input_odp) {
                    echo '<script type="text/javascript">alert("Data cannot uploaded")</script>';
                }
                if ($run_input_odp) {
                    echo '<script type="text/javascript">alert("Data successfully uploaded")</script>';
                }
            } else {
                echo 'Chose only csv file';
            }
        } else {
            echo 'Plese Select the file first...!!!';
        }
    }
    ?>
    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="excelFile"/>
        <input type="submit" name="importodp" value="Import Data from Excel"/>
    </form>

</body>
</html>

but the return that i get is :

Warning: mysqli_error() expects exactly 1 parameter, 0 given on line 21

Do i doing it wrong?

Syntax : mysqli_error(connection);

Parameter : connection

Description: Required. Specifies the MySQL connection to use Required. Specifies the MySQL connection to use

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM