Trouble importing data

admin

Administrator
Staff member
I am unable to import a text file containing tab delimited data into a mySQL table. I tried phpmyadmin on my local server and on my ISP's server and a simple PHP file containing LOAD DATA. I am unable to get any of the three methods to work without an error.

When I "Insert text files into table" using phpmyadmin on my local server, the error I get is "MySQL said: File 'c:php4php7025.tmp' not found (Errcode: 2)".

When I "Insert text files into table" using phpmyadmin on my local server, the error I get is "MySQL said: The file '/tmp/php9klZ2t' must be in the database directory or be readable by all".

Here is the simple PHP file containing LOAD DATA that I tried on my local server, but it fails on the LOAD DATA query.

$db=mysql_connect("localhost","root");

mysql_select_db("test",$db);

$result = mysql_query("DELETE FROM songs") or die ("Invalid DELETE query");

$result = mysql_query("OPTIMIZE TABLE songs") or die ("Invalid OPTIMIZE query");

$result = mysql_query("LOAD DATA LOCAL INFILE 'importfile.txt' INTO TABLE songs") or die ("Invalid DATA LOAD query");
 
Back
Top