hi,
i am trying to import the text file into database table. but it is giving the error. in text file fields are First Name, Last Name, EmailId. In data.txt has some inforation about the users.
mohan, rao, rao@gmail.com.
johson, jee, jee@yahoo.com
i want to import into database. i am not getting how to read the entair data in the file. Please give some idea.
Regards,
Prakum.
How to import the txt file to database table
Moderator: General Moderators
Re: How to import the txt file to database table
probably the sql statement in your text file has syntax error.
Re: How to import the txt file to database table
Post your code and the error... then we can help you.
Please use [ code ] tags.
Please use [ code ] tags.
Re: How to import the txt file to database table
Use the following MySQL Query
Note:
1.Your table should have same number of fields as in your text file for proper import.
2.You have to store your text file in mysql/data directory before executing above command.
Code: Select all
<?php
mysql_query("LOAD DATA INFILE 'filename.txt' INTO TABLE 'tablename' FIELDS TERMINATED BY ','");
?>
1.Your table should have same number of fields as in your text file for proper import.
2.You have to store your text file in mysql/data directory before executing above command.