How PHP reads txt text content into MySQL database

Source: Internet
Author: User
PHP how to read txt text content stored in MySQL database!
This post was last edited by Pigpighappy on 2012-12-17 17:07:47

Ask the great God to answer Ah! How does PHP read txt text content into MySQL database? Please complete the code! Fit to add points! The little woman thanked her!


------Solution--------------------
This depends on your txt in the database field is not written by the way if it is good to do, I do, I use TXT to add the e-mail address
Only one address is required per line

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 (' Ymd '). Time (). $p;
Move_uploaded_file ($_files[' text ' [' Tmp_name '], $file);

$get =fopen ($file, ' R ');
$j = 0;
while (!feof ($get)) {//loops through each row
$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 "";
}
}else{
echo "";
}
Fclose ($get);
  • Related Article

    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.