Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP加载数据填充仅适用于根目录_Php_Mysql_Mysqli - Fatal编程技术网

PHP加载数据填充仅适用于根目录

PHP加载数据填充仅适用于根目录,php,mysql,mysqli,Php,Mysql,Mysqli,我有一个PHP脚本,可以使用LOAD DATA INFILE将csv文件导入MySQL表。该查询适用于MySQL中的root用户和非root用户,但是当从PHP脚本运行查询时,它只适用于root用户 我相当肯定我已经正确设置了所有权限,甚至通过授予非root用户完全权限进行了测试 我是否缺少任何可以阻止用户运行查询的内容 以下是脚本: $files = scandir('/var/www/html/imports/pigsback/'); foreach($files as $file) {

我有一个PHP脚本,可以使用LOAD DATA INFILE将csv文件导入MySQL表。该查询适用于MySQL中的root用户和非root用户,但是当从PHP脚本运行查询时,它只适用于root用户

我相当肯定我已经正确设置了所有权限,甚至通过授予非root用户完全权限进行了测试

我是否缺少任何可以阻止用户运行查询的内容

以下是脚本:

$files = scandir('/var/www/html/imports/pigsback/');

foreach($files as $file) {
    if ($file != '.' && $file != '..') {
        $import = 
            "LOAD DATA INFILE '/var/www/html/imports/pigsback/$file'
            IGNORE INTO TABLE pigsback.temp_import
            FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
            LINES TERMINATED BY '\n'
            IGNORE 1 LINES
            (@deal_id, @voucher_headline, @item_sku, @purchase_date, @first_name, @last_name, @address_1, @address_2,
            @address_3, @address_4, @postcode, @region, @phone, @delivery_note, @sequence_id, @deal_price, @country)
            SET deal_id=@deal_id, voucher_headline=@voucher_headline, item_sku=@item_sku, purchase_date=@purchase_date, 
            first_name=@first_name, last_name=@last_name, address_1=@address_1,address_2=@address_2, address_3=@address_3, 
            address_4=@address_4, postcode=@postcode, region=@region, phone=@phone, delivery_note=@delivery_note, 
            sequence_id=@sequence_id, deal_price=@deal_price, country=@country";

        if(! mysqli_query($connect, $import)) {
            echo 'Failed: ' . $file . PHP_EOL;
        }
        else {

        }
    }
}