LOAD DATA LOCAL INFILE PHP Error

  • Hi All,

    I hope someone can help me with a problem I recently run into.

    I am currently working on a wordpress plugin and I am trying to populate a database table via a CSV file. I am using the famous LOAD DATA LOCAL INFILE but I am getting some error which I hope someone can help resolve for me.

    When I use LOAD DATA LOCAL INFILE I get the error "File not Found" and

    When I use LOAD DATA INFILE I get the error "Access Denied for user .. "

    I have tested them out on the server as well as WAMP. I also tried changing the permissions of the file but I am still getting the same errors.

    Code:

    function load_table() {

    global $wpdb;

    $filename = 'upper_db_.csv';

    $table_nme = $wpdb->prefix . "upper_winds";

    $sql = "LOAD DATA INFILE '" . $filename . "'

    INTO TABLE $table_nme

    FIELDS TERMINATED BY ','

    ENCLOSED BY '\"'

    ESCAPED BY '\"'

    LINES TERMINATED BY ''

    ";

    $wpdb->query($sql);

    }

    Thanks, would very much appreciate your help.

  • OK I may have found the issue but I still need some help. Whilst I am escaping the " I have found out that the path \ are not being inserted into the actual path. Tried to escape them but having some trouble.

    Any ideas how I can get around this?

    Thanks

  • For anyone who may run into something similar this is the code I used to get this working.

    $filename = str_replace("//","//////",__DIR__ ."/file.csv");

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply