How does php read txt text and store it in the mysql database! This post was last edited by pigpigpighappy from 2012-12-1717: 07: 47! How does php read txt text and store it in the mysql database? Complete Code! Suitable for extra points! Thank you! ------ Solution --------- How does php read txt text and store it in mysql database!
This post was last edited by pigpigpighappy at 17:07:47, January 17 ,.
Please help me! How does php read txt text and store it in the mysql database? Complete Code! Suitable for extra points! Thank you!
------ Solution --------------------
It depends on whether your txt file is written in the form of database fields. If yes, I will do this, and I will use txt to add an email address.
Each line requires only one address
// Upload txt text
If ($ _ FILES ['text'] ['name']) {
$ Path = '../upload ';
If (! File_exists ($ path )){
Mkdir ($ path );
}
If (! Is_dir ($ path )){
Mkdir ($ path );
}
$ P = strrchr ($ _ FILES ['text'] ['name'], '.');
If (preg_match ("/txt/", $ p )){
$ File = $ path. '/'. date ('ymmd'). time (). $ p;
Move_uploaded_file ($ _ FILES ['text'] ['tmp _ name'], $ file );
$ Get = fopen ($ file, 'r ');
$ J = 0;
While (! Feof ($ get) {// read each row cyclically
$ Row = fgets ($ get );
$ Row = str_replace ('','', $ row );
$ Rowa = preg_match ("// \@/", $ row );
$ SQL = "INSERT INTO 'address' ('address', 'timees', 'data') VALUES ('". $ rowa. "', '0', 1 )";
$ Db-> guery ($ SQL );
$ J ++;
}
}
Echo "script" alert ('added $ j'); history. back (); script ";
}
} Else {
Echo "script" alert ('select the correct adding method'); history. back (); script ";
}
Fclose ($ get );