When I load data in from a file, I always make sure that the data is seperated using a character which doesn't occur within the data itself - eg if you have data with spaces in it, then don't use space a seperator. eg LOAD DATA LOCAL INFILE "countries.txt" INTO TABLE Countries FIELDS TERMINATED BY ';'; If however you only have single column data, then your problem is probably in the file format - DOS and UNIX use different line terminators. By default, MySQL will look for the newline character (\n) to terminate lines. If you have a good text editor (ie not NotePad) then you should be able to convert the file format from DOS to UNIX (some kind of save as command usually), and hey presto, your problem should go away. You should also check that there isn't actually a space at the end of each line in your text file? Failing that, try specifying the line terminator eg LOAD DATA LOCAL INFILE "countries.txt" INTO TABLE Countries LINES TERMINATED BY ' \n'; (the syntax I've exampled will terminate lines when it encounters the space_newline combination) Tom Mitchell Kirschner wrote: > If you're unable to get to the bottom of this problem, you could probably > use PHP's trim() function to massage the data after the table's been > created. The basic algorithm would be to iterate through each record and > replace e.g. $country_name with trim ( $country_name ). Annoying to do, but > much quicker than manually entering data. Again, that suggestion applies > only if somebody doesn't have insight into the underlying cause. > > Mitch > > >-----Original Message----- > >From: James Duncan [mailto:[EMAIL PROTECTED]] > >Sent: Sunday, March 04, 2001 5:21 PM > >To: [EMAIL PROTECTED] > >Subject: [PHP-WIN] Reading data from MySQL > > > > > >Hi folks, > > > >I have a problem. I think it's the way I'm inputting data into MySQL table. > >What I'm trying to do is insert data from a DOS text file into a MySQL > >Table. The DOS text file has a country name on each line, like: > > > >United Kingdom > >United States > > > >I'm trying to populate a MySQL table called Countries from the MySQL client > >like: > > > >LOAD DATA LOCAL INFILE "countries.txt" INTO TABLE Countries; > > > >All the records are created but when I echo them to screen with PHP every > >country has a space after it, like: > > > >"United Kingdom " > > > >What am I doing wrong? It's not my PHP code because if I create a table and > >manually fill it with values the space isn't present. However, I don't want > >to manually have to enter 290 odd countries into the table! So I'm assuming > >it's the input file format or I'm missing something on the LOAD DATA > >command? However, I have tried saving in every format present in Word (such > >as Text Only, MS DOS Only, etc) but with no success. > > > >The MySQL documentation says you can set the end of line marker explicitly > >in the LOAD DATA statement. How do you do this? > > > >Many thanks > > > >James > > > > > > > >-- > >PHP Windows Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED]
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]