thryb Posted November 16, 2007 Share Posted November 16, 2007 Good day, Is there an easy way to insert a list of country (from a txt file) in a mysql database? Or does it have to be done one by one (I doubt it ). Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/77630-inserting-country-list-in-mysql-from-file/ Share on other sites More sharing options...
~n[EO]n~ Posted November 16, 2007 Share Posted November 16, 2007 You can do it through PHP, fetch the content from text file and insert into MySQL table. Just like this example <?php // get contents of a file into a string $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); ?> Link to comment https://forums.phpfreaks.com/topic/77630-inserting-country-list-in-mysql-from-file/#findComment-392940 Share on other sites More sharing options...
thryb Posted November 16, 2007 Author Share Posted November 16, 2007 thats what I was thinking, just wanted to be sure there was no other fast way right in mysql or pma. Thanks Neo Link to comment https://forums.phpfreaks.com/topic/77630-inserting-country-list-in-mysql-from-file/#findComment-392943 Share on other sites More sharing options...
~n[EO]n~ Posted November 16, 2007 Share Posted November 16, 2007 If your text file is encoded ANSI, then you can import in MySQL through phpMyAdmin. There is a option for Format of SQL file, select ANSI and there you go. P.S I have never tried that Link to comment https://forums.phpfreaks.com/topic/77630-inserting-country-list-in-mysql-from-file/#findComment-392948 Share on other sites More sharing options...
thryb Posted November 16, 2007 Author Share Posted November 16, 2007 Allright, Ill give a try! Never seen it before, Ill look for it. Thanks much! Link to comment https://forums.phpfreaks.com/topic/77630-inserting-country-list-in-mysql-from-file/#findComment-392959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.