Page 1 of 1

error in uploading a .csv file in a table using phpMyAdmin

Posted: Tue Feb 21, 2012 4:28 pm
by PHP_mySQL__Newbie
I am trying to upload a data file rabc.csv in a table rabc.csv of my database using PHPmyAdmin. The file rabc.csv resides in the folder htdocs/p/dataFiles/rabc.csv and was uploaded using 'put files' in dreamweaver. I am receiving an error on PhPAdmin. Can anyone please give me an idea what is this error about?

Error:
MySQL said:
#13 - Can't get stat of '/var/lib/mysql/htdocs/p/dataFiles/racl.CSV' (Errcode: 2)


SQL query:

Code: Select all

LOAD DATA INFILE'htdocs/p/dataFiles/rabc.csv' INTO TABLE rabc
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"' 
LINES TERMINATED BY '\r\n' IGNORE 1LINES ;

Re: error in uploading a .csv file in a table using phpMyAdm

Posted: Tue Feb 21, 2012 6:06 pm
by Celauran
The file doesn't exist. Look at the path in the error message; seems unlikely that's where you uploaded it. Try using an absolute path rather than a relative one, or just use the file upload in the phpMyAdmin GUI.

Re: error in uploading a .csv file in a table using phpMyAdm

Posted: Tue Feb 21, 2012 6:14 pm
by PHP_mySQL__Newbie
Thank you for your reply. I may sound naive. How would an absolute path look like?

Code: Select all

LOAD DATA INFILE'http://mywebsite.com/p/dataFiles/rabc.csv' INTO TABLE rabc     ?????
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"' 
LINES TERMINATED BY '\r\n' IGNORE 1 LINES ;


I won't be able to use this path if my folders are protected.

Re: error in uploading a .csv file in a table using phpMyAdm

Posted: Tue Feb 21, 2012 6:20 pm
by Celauran
PHP_mySQL__Newbie wrote:How would an absolute path look like?
Absolute paths begin with /. Beyond that will depend on your host's setup. Check $_SERVER['DOCUMENT_ROOT']

Re: uploading a .csv file in a table

Posted: Tue Feb 21, 2012 7:35 pm
by PHP_mySQL__Newbie
PhpMy Admin worked on the remote server. This is what I am going to use from now. Thank you.
I have read articles and tutorials online about uploading .csv files in a table. Most of the articles or tutorials that I found, explained how to upload a file as a field of a table NOT as inserts in a table.

To name a few:
http://www.w3schools.com/php/php_file_upload.asp
http://php.about.com/od/advancedphp/ss/ ... upload.htm
http://www.tizag.com/phpT/fileupload.php

These articles/tutorials didn't help me. I was able to load data from a .csv file into a table on my localhost though.

Code: Select all

LOAD DATA LOCAL INFILE  
'C://Users/newbie/rabc.csv'
INTO TABLE rabc
IGNORE 1 LINES