To import a csv file to mysql, do you need to create a new table? Solution

Source: Internet
Author: User
To import a csv file to mysql, do you need to create a new table? I have a CSV file to import it to mysql. do you need to create a table first and then create a new field, I tried to create a table, created a field, and used phpmyadmin to import the table. An error occurred while prompting whether to create a new table when importing the InvalidfieldcountinCSVinput csv file to mysql.
I have a CSV file that needs to be imported into mysql. Do I need to create a table first and then create a field? I tried to create a table and a field myself, then use phpmyadmin to import the data, and an error occurs. The message displayed is Invalid field count in CSV input on line 1.

I don't know why ~ Excuse me, thank you.


Oh, none of them can insert attachments, but they can have external links... Isn't it?

------ Solution --------------------
$ Con = mysql_connect ("localhost", "peter", "abc123 ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}

// Create database
If (mysql_query ("create database my_db", $ con ))
{
Echo "Database created ";
}
Else
{
Echo "Error creating database:". mysql_error ();
}

// Create table
Mysql_select_db ("my_db", $ con );
Mysql_query ("set names utf8 ");
$ SQL = "CREATE TABLE name
(
PartyID varchar (60 ),
Fully NAME varchar (100 ),
Local NAME varchar (100 ),
... // All columns in CVS
)";

// Execute query
Mysql_query ($ SQL, $ con );

Mysql_close ($ con );
?>
------ Solution --------------------
Invalid field count in CSV input on line 1.
The input field in the CSV file of 1 rows is invalid.

Make sure that the data type of G is correct!
The first line (the title line) should be skipped during import)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.