sovandy Posted November 19, 2009 Share Posted November 19, 2009 Dear everyone here! I need your help very soon. I wanna read a .txt file that has many records and lines. I have to generate that record into database. in each lines that need to be entered to field of database are separated by tab. Please see my code: $original = fopen("test.txt","r+"); //$new_file = fopen("query.txt","w"); while(!feof($original)) { $line = fgets($original); $token = strtok($line, " "); while ($token != false){ $comma_line = $comma_line.", "; $token = strtok(" "); } //$query_line = "insert into my_table ('')"; } fclose($original); I do hope to get your help soon. Thanks! Link to comment https://forums.phpfreaks.com/topic/182123-read-a-file-to-write-in-other-file-or-database/ Share on other sites More sharing options...
Mchl Posted November 19, 2009 Share Posted November 19, 2009 Sure. Just say what your problem is. Link to comment https://forums.phpfreaks.com/topic/182123-read-a-file-to-write-in-other-file-or-database/#findComment-960922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.