
- You are not logged in. | Login
March 6, 2007 11:35 am
- monkeydude
- Member


Help with LOAD DATA INFILE
I make like this
loaddata.php
---------------------
<?php
/* Connecting, selecting data base */
$link = mysql_connect("localhost", "root", "")
or die("Could not connect : " . mysql_error());
print "Connected successfully";
mysql_select_db("servise") or die("Could not select database");
/* Accomplish SQL-request */
$load="LOAD DATA INFILE "./a.txt" REPLACE INTO TABLE work IGNORE 1 LINES";
mysql_query($load);
if (!mysql_error())
echo "Data refreshed successfully! ";
else echo "Data base error. MySQL writes:", mysql_error();
?>
---------------------Lies a.txt even where loaddata.php is i.e. displays an error in the root of the site
Parse error: syntax error, unexpected '/' in d:\www\loaddata.php on line 17
If it lies in the data base catalogue and $load="LOAD DATA INFILE /"a.txt/" REPLACE INTO TABLE work IGNORE 1 LINES";
Everything is all right.
March 6, 2007 1:22 pm
- yendii
- Member


Re: Help with LOAD DATA INFILE
Parse error: syntax error, unexpected '/' in d:\www\loaddata.php on line 17
What is unclear?
Data bases have nothing to do with it.
March 6, 2007 1:34 pm
- monkeydude
- Member


Re: Help with LOAD DATA INFILE
I understand that data base has nothing to do with it.
How to indicate to LOAD DATA INFILE where this file should be taken?
March 6, 2007 1:43 pm
- monkeydude
- Member


Re: Help with LOAD DATA INFILE
That’s what I found.
In cases when files are placed on the server the last one acts according to the following rules:
If absolute (full) path to the file is set, the server uses this path without any changes.
If relative path to the file is set with indication of one or more source catalogues, the file search will be provided with regard to indicated catalogues in the catalogue of the server data (datadir).
If path to the file is given without indication of the source catalogues, server searches this file in the directory of the data base used.
From it follows that file set up like `./myfile.txt' is read from the server data catalogue by the time when file set up as `myfile.txt' is read from the catalogue of the data base used. For instance, the next LOAD DATA command reads file data.txt in the data base catalogue for db1 as far as db1 is the current data base even if this command obviously contains instruction to load file in the table of data base db2:
mysql> USE db1;
mysql> LOAD DATA INFILE "data.txt" INTO TABLE db2.my_table;
But the problem is not in SQL but in PHP
I’ve made
$load="LOAD DATA INFILE './a.txt' REPLACE INTO TABLE work IGNORE 1 LINES";
Now SQL writes File './a.txt' not found (Errcode: 22) although it is present
March 6, 2007 2:19 pm
- monkeydude
- Member


Re: Help with LOAD DATA INFILE
Thanks to everyone.
$load="LOAD DATA INFILE 'D:/AppServ/www/img/a' REPLACE INTO TABLE work IGNORE 1 LINES";
That’s all


