[thelist] merging a dictionary to sql table
Alex Beston
alex at deltatraffic.co.uk
Wed Nov 16 01:53:56 CST 2005
hi Kirill,
>
>It's interesting what is the structure of the dictionary file?
>("ENGLDICT.TXT")
>
>
ok heres a sample:
a
AAAS
aardvark
aardvarks
Aarhus
Aaron
Ababa
aback
abacterial
abacus
and so on
>Probably better use another function file();
>
>This function creates the array from the file with lines.
>
>$linesarray = file("ENGLDICT.TXT")
>
>
yup agreed.
>And the next question:
>
>Do you have this file "ENGLDICT.TXT" in the same directory? (case-sensitive)
>
>Try check if file open or not.
>
yes, pretty sure we're ok there, but good point. im not getting a
filenot found type error.
and Matt:
> I suspect your $query here isn't what you think it is.
thinks your right there.
> Have you output
its value?
> mysql_query($foo) or die(mysql_error());
ok just added this. i now have this:
hereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereherehereYou
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 's'' at line 1
using this:
while (!feof($handle)) {
echo "here";
$buffer = trim(fgets($handle, 4096));
$query_string = "SELECT word FROM word_list WHERE word =
'$buffer'";
$result = mysql_query ($query_string) or die(mysql_error());
if(!$result){
echo "there";
$query = "INSERT into word_list(word) VALUES ('$buffer')";
mysql_query($query);
I suspect i have some dodgy characters in the source word list
> define(TEST_MODE, true);
...
> mysql_query($foo) or (TEST_MODE and die(mysql_error()));
neat tip ! thanks!
A.
More information about the thelist
mailing list