Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Errcode: 2 when running LOAD DATA LOCAL INFILE on server

Status
Not open for further replies.

cn

Technical User
Apr 17, 2002
2
CA
Hi.
This is the script I write to upload a .csv file into my online mysql database :

$sql_query="LOAD DATA LOCAL INFILE '$textfile' INTO TABLE purchase FIELDS TERMINATED
BY ',' (purchase_order,job_no,username,model,quantity,due_date,sent_date,courier_servi
ce,remark)";

$sql_query=($sql_query);
$result=mysql_query($sql_query);
$error_message=mysql_error();
if(!$result)
{
echo&quot;Error : $sql_query<br><p>&quot;;
echo&quot;$error_message&quot;;
}
else if($result)
{
echo&quot;$sql_query<br><p>&quot;;
echo&quot;successful&quot;;
}

When I try to run the script in localhost, it is work.But when I try in the server,it
can't work and return the error message like that :

Error : LOAD DATA LOCAL INFILE 'C:\\purchase3.csv' INTO TABLE purchase FIELDS
TERMINATED BY ',' (purchase_order,job_no,username,model,quantity,due_date,sent_date,co
urier_service,remark)

File 'C:\purchase3.csv' not found (Errcode: 2)


I think it maybe the backsplashes that make the error occur..

so I change the script like that :

$sql_query=stripslashes($sql_query);

But it still return the error message like that :

Error : LOAD DATA LOCAL INFILE 'C:\purchase3.csv' INTO TABLE purchase FIELDS
TERMINATED BY ',' (purchase_order,job_no,username,model,quantity,due_date,sent_date,co
urier_service,remark)

File 'C:purchase3.csv' not found (Errcode: 2)



The error occur above while I am using IE 5.5. But when I using Netscape 4.7 to run it..it work..it return the message like that :

LOAD DATA LOCAL INFILE '\temp\phpAJFME' INTO TABLE purchase FIELDS
TERMINATED BY ',' (purchase_order,job_no,username,model,quantity,due_date,sent_date,co
urier_service,remark)



the different is between the file that IE and netscape reading..the IE read file in c:\purchase3.csv but the netscape read file in \temp\phpAJFME ..... and netscape can work but IE can't.

The actual location of my file is on c:\purchase3.csv.


What happen actually...hope that somebody can help me. Thanks
 
When you load a file into a database on the server, you are actually loading the file AFTER it has been uploaded to the server. The server cannot load a file from your local machine onto the server.

You need to tell the query that you are loading the temporary file on the server which in fact is the name of the field you assigned to the input field:
form:
<input type=&quot;file&quot; name=&quot;txtfile&quot;>
server:
$txtfile becomes the name of the temporary file on the server.

If you did this, and you are still having problems, check to make sure the temporary files are being stored on the server in your temporary location (upload_tmp_dir). If not, that is definitely where your problem is.

Chad. ICQ: 54380631
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top