Jump to content


Photo

Problem importing flat file data into MYSQL


  • Please log in to reply
1 reply to this topic

#1 mclard

mclard
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 September 2006 - 09:53 AM

Hi
Im trying to import the contents of a flat text file into a mysql database, what ive got so far kind of works but it only enters the first line. The more i look at it it looks like mysql syntax but im at a loss of what to do. Can anyone offer any advice.
FLAT FILE FORMAT...
entry1
entry2
entry3
 $dbname="project";
$dbc = @mysql_connect ('localhost', 'root', '') or die (mysql_error());
@mysql_select_db("$dbname"); 
$SQL = "LOAD DATA LOCAL INFILE 'path to file' INTO TABLE `user` FIELDS TERMINATED BY ' ' ENCLOSED BY '' ESCAPED BY ' ' LINES TERMINATED BY '\r\n'";
$result = mysql_query($SQL); 


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 06 September 2006 - 10:25 AM

try
$SQL = "LOAD DATA INFILE 'path to file' 
           INTO TABLE `user` 
           FIELDS TERMINATED BY '  ' 
           LINES TERMINATED BY '\r\n'";

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users