I'm having some trouble importing a database into MySQL. I use PHPmyAdmin to administer my databases, and I have all my data in an Excel spreadsheet. I tried saving the Excel spreadsheet first as a .txt (tab-delimited) file, then as .csv (comma-delimited) file. I logged into PHPmyAdmin, went to my table, then clicked on the "insert data from a textfile into table" link. I put in the file name and clicked on submit. It added 397 records to my table, but when I went to browse my table, all I had were records with NULL in each field. Does anyone know why it did this and how I can import my data into this table?

I've read some of the other posts on importing an Excel file in MySQL and I thought I was doing it right by saving it as a text file, then importing through PHPmyAdmin, but I must have done something wrong.

Any ideas on how to fix this would be greatly appreciated.

Thanks in advance.

    Try using mysqlfront (look for the addres in google) it has very good .csv options and works great!
    But if for any reason you got to use php my admin ensure that you have a primary key and put all the fields on your excel file plus the primary key field's name firts.

    Hope that helps.

      Thanks. I don't have to use PHPmyAdmin. It was just convenient to use since it was already on my server. I'll take a look at this mysql front. However, I just noticed that I have a field called ID in my database table, but no field like that in my Excel table. Could that be why it's not importing correctly? Should I try adding that extra field into my Excel table, then import again?

      M.

        No you don't need to add the id field in the excel file, just espesify the names of the fields in phpmyadmin and be sure not to use the name of de ID field in that list for example if mysql table is

        ID|some_field|some_other_field|etc_field

        in the list inculde some_field|some_other_field|etc_field

          Does PHPMyAdmin have an administration tool for transferring fies? I used a direct query to MySql through a PHP form, so if you are doing it any way then by query my input will have very little impact to the discussion.

          The default behavior when transferring uploading a text file into MySql is to have the same number of fields in each with tab delimitted values and lines ending on a new line (\n). Anything other than that you need to specify it in your sql statement.

          I did have some trouble one time because windows was terminating my lines with \r\n when I saved from Excel so I had to clean that up because MySql did not like getting a carriage return in a numeric field.

          This page might be of help if you haven't seen it:
          http://www.mysql.com/doc/en/LOAD_DATA.html
          This post is where I was talking about my experiences with importing data files:
          http://phpbuilder.com/board/showthread.php?s=&threadid=10206884

            Write a Reply...