[] It's really urgent to wait online. [] CVS imports mysql garbled characters. please kindly advise. I can only give them if I have no points. please forgive me that this post was last posted by etracer between 2013-02-1910: 04: 06 editing my CVS file format is UTF8, and the database format is utf8_general_ci. The following is my code. please refer to [] for more information, such as [] CVS importing mysql garbled code, please give me some advice. I have no points but to give them. please forgive me.
At the end of this post, etracer edited the CVS file format UTF8 at 10:04:06, and the database format utf8_general_ci.
The following is my code. For more information, see
/**
* @ Author: zookeeper has been created
* @ Modify:
*/
// ================================================ ====
// Common settings
// ================================================ ====
// Smarty. class calls extract
Require_once ('../libs/MySmarty. class. php ');
// The new worker is generated as a worker MySmarty worker
$ Smarty = new MySmarty ();
If (! Include_once ("postdbonload. php "));
// Zookeeper has been connected to zookeeper
$ Pdo = new PDO ("mysql: host = $ MYSQL_HOST; dbname = $ MYSQL_DATABASE", "$ MYSQL_USER", "$ MYSQL_PASSWORD ");
$ Pdo-> setAttribute (PDO: ATTR_ERRMODE, PDO: ERRMODE_EXCEPTION );
$ Pdo-> query ('set NAMES utf8 ');
$ Pdo-> setAttribute (PDO: MYSQL_ATTR_USE_BUFFERED_QUERY, true );
$ Pdo-> query ('set character set utf8 ');
$ Pdo-> query ('set CHARACTER_SET_RESULTS = utf8 ');
$ Action = $ _ GET ['action'];
If ($ action = 'import '){//
$ Filename = $ _ FILES ['file'] ['tmp _ name'];
If (empty ($ filename )){
Echo 'csv syntax Syntax example: optional syntax Syntax example ';
Exit;
}
$ Handle = fopen ($ filename, 'r ');
$ Result = input_csv ($ handle );//
$ Len_result = count ($ result );
If ($ len_result = 0 ){
Echo 'no response has been completed ';
Exit;
}
For ($ I = 1; $ I <$ len_result; $ I ++ ){//
$ M_personalid = $ result [$ I] [0]; // individual employee response
$ M_membername = $ result [$ I] [1]; // member name
$ M_katakana = $ result [$ I] [2]; // your region has been deleted
$ Gname = trim ($ result [$ I] [3]); // branch store
$ Group2id = "select * from hy_groups where g_groupname = '$ gname '";
$ Rs = $ pdo-> query ($ group2id );
$ Rs-> setFetchMode (PDO: FETCH_BOTH );
$ Result_arr = $ rs-> fetch ();
$ M_groupid = $ result_arr ['G _ id'];
$ M_driver_tel = $ result [$ I] [4]; // your phone number
$ M_driver_tel = $ result [$ I] [5]; // carries the nickname
$ M_driver_tel = $ result [$ I] [6]; // call number (from House)
$ M_driver_tel = $ result [$ I] [7]; // your responsibilities
$ M_pro = $ result [$ I] [20]; // submit test
//-----------------------
$ C_clientname = $ result [$ I] [8]; // Configure the clientname first)
$ C_clienttel = $ result [$ I] [9]; // call your phone number
$ C_clientplace = $ result [$ I] [10]; // The first domicile of the delegate.
$ C_traveler = $ result [$ I] [11]; // The name of the passenger who owns the taxi
$ C_traveleradds = $ result [$ I] [12]; // A passenger who owns the house
$ C_travelermob = $ result [$ I] [13]; // A passenger's phone number (with an alias)
$ C_travelertel = $ result [$ I] [14]; // A passenger's phone number (from home)
$ C_secretary = $ result [$ I] [15]; // secret name
$ C_secretarytel = $ result [$ I] [16]; // assume the phone number of the secret (add/attach ticket)
$ C_carinfo = $ result [$ I] [17]; // vehicle conditions
$ C_goodpart = $ result [$ I] [18]; // car room conditions
$ C_emptycol = $ result [$ I] [19]; // null condition
//------------------------
$ Data_values = "('$ m_personalid', '$ m_membername', '$ m_katakana', '$ m_groupid', '$ m_driverkmtel', '$ m_driver_tel', '$ m_driverhometel ', '$ m_salesstaff', '$ m_pro ')";
$ Querysql = "insert into hy_members (m_personalid, m_membername, m_katakana, m_groupid, m_driverkmtel, m_driver_tel, clerk, m_salesstaff, m_pro) values $ data_values ";//
$ Query = $ pdo-> exec ($ querysql );
If ($ query ){
} Else {
Echo'
Window. alert ("import failed"); window. location = "Crew_Send.php"; script ';