...

View Full Version : Can't find word in database, but it is there...



martynball
04-26-2012, 01:41 AM
I have now managed to get a dictionary into a database. But for some reason the search feature of MyPHPAdmin can't find some words, nor can PHP scripts :S

http://martynleeball.goodluckwith.us/test.php
There is a list of the words, now if you search down that list you will see that "mobile" is in the list.
(Code of the page):


<?php
require "php/connect.php";

$query = "SELECT * FROM 'dictionary'";
$result = mysql_query("SELECT * FROM dictionary") or die(mysql_error());

while ($row = mysql_fetch_array($result)) {
print_r($row['word']);
echo "<br />";
}
?>


But if I do something like below, it does not work ("true" isn't printed on the screen):


<?php
require "php/connect.php";

$query = "SELECT * FROM 'dictionary'";
$result = mysql_query("SELECT * FROM dictionary") or die(mysql_error());

while ($row = mysql_fetch_array($result)) {
if($row['word'] == "mobile") {
echo "true";
}
}
?>

tangoforce
04-26-2012, 02:10 AM
Two immediate things that spring to mind to check..

1) Make sure you have no hidden characters in there with the word - eg a return (\n) or a tab (\t)

2) Make sure the encoding is the same on the input and output pages (ANSII / ISO / UTF8) otherwise mysql may store them differently to the ouput script searching them. I'm still not 100% on this myself as I had a massive headache with another project using utf8 recently however if you do have any problems in this area it can cause symptoms you describe.

martynball
04-26-2012, 02:47 AM
Perfect cheers, I just used trim, and also re-added the words to the database and trimed them before. Only thing I need to do now is create a word ranking system as so many random words that are a load of crap come up in searches lol.

Should use a better dictionary really.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum