[thelist] merging a dictionary to sql table

Alex Beston alex at deltatraffic.co.uk
Wed Nov 16 01:04:39 CST 2005


hi List

im trying to merge one dictionary with another already in a couple of 
columns of a dictionary table. heres my code. its not really working - 
no words get inputted to the dictionary

any ideas appreciated

Alex

<?
$time_start = microtime(true);
include("database/connect-dictionary.php");
$handle = fopen("ENGLDICT.TXT", "r");
$counter=0;
if ($handle) {
    while (!feof($handle)) {
        $buffer = trim(fgets($handle, 4096));
        $query_string = "SELECT word FROM word_list WHERE word = 
'$buffer'"; 
         
        $result = mysql_query ($query_string);// or die("not working1"); 
         
        if(!$result){  // this might be a bad way to do it
            $query = "INSERT into word_list(word) VALUES ('$buffer')";
            mysql_query($query);
            $counter++;
        }     
    }
fclose($handle);
}
mysql_close($link);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "words added".$counter;
echo $time;
?>



-- 
-_-_-_-_-_-_-_-_-_-_-

  deltatraffic.co.uk

  Current Location:
  KL, Malaysia
 
_-_-_-_-_-_-_-_-_-_-_




More information about the thelist mailing list