January 24, 2015 at 4:40 am
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.
January 24, 2015 at 7:27 am
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
January 29, 2015 at 6:18 am
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 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy