简体   繁体   English

在PHP中加载数据infile不起作用

[英]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 我尝试使用加载数据infile在php中制作上传菜单,导致我需要上传的文件太大

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 警告:mysqli_error()恰好需要1个参数,第21行给出0

Do i doing it wrong? 我做错了吗?

Syntax : mysqli_error(connection); 语法: mysqli_error(connection);

Parameter : connection 参数: connection

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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