TIME NOW
World current time now,
CALENDAR
Calendar monthly, yearly
login GOLD PRICE, RATE
login HOROSCOPE
login DICTIONARIES, LISTS
login SCIENCE EDUCATION RELIGION
login FINANCE, BUSINESS
login WORLD COUNTRIES, WIKI

PHP scripts, code, examples, tutorial

Previous articlePage bottomNext article  ALL TOPICS

PHP. MYSQL. Insert data from text file to table

 

<?php

if (!$link = mysql_connect('localhost', 'root', 'password')) {
   echo 'Could not connect to mysql';
      exit;
      }
     
      if (!mysql_select_db('joomla_banner_exchange', $link)) {
         echo 'Could not select database';
        exit;
        }
       
    mysql_query ("set names 'utf8'");

      $dir = getcwd()."/";
      $handle = fopen ( $dir ."file.txt", "r");
      
      if ($handle) {

       while (!feof($handle)) {
            
           $line = fgets ($handle , 4046);   
           mysql_query ("insert into t_data set  text = '$line', lang = 'en' , date_create = '$date'") ;
               
        }      
      
     }//while
       
fclose($handle);
     
?>

 
Previous articlePage topNext article  ALL TOPICS



 Use username: Guest, Anonymous, Programmer






QUOTES:
Normal life cannot sustain revolutionary attitudes for long.
Milovan Djilas
The great art of life is sensation, to feel that we exist, even in pain.
Lord Byron
Why is it that we will laugh at a man in a clown outfit, but we won't laugh at a man just walking down the street carrying a clown outfit in one of those plastic dry-cleaner bags
Jack Handey Deep Thoughts