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! Quote 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); ?> Quote 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 Quote 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 Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.