Insert Words from text file to database
        by Mohan[ Edit ] 2014-01-17 18:44:34 
         
        
        	
Hai,
 Here is sample code to insert words from a text file into database table
<?php
    $lines = file("words.txt", FILE_IGNORE_NEW_LINES);
    $username = "root";
    $password = "";
    $hostname = "localhost";
    $dbname = "sample";
    $tablename = "englishwords"; 
    $cn=mysql_connect($hostname,$username,$password);
      if(!$cn)
      {
       //  echo "database not connected";
          
      }
      else{
          //echo "database selected";
      }
      
      $link=mysql_selectdb($dbname,$cn);
      if(!$link)
       {
          echo "Table not selected";
       }
      else
      {
          //echo "table selected";    
      }
      foreach($lines as $val)
      {
      $query= mysql_query("INSERT INTO  `sample`.`englishwords` (`id` ,`words`) VALUES ('',  '$val')");
      }
      ?>