Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post

    Can't find word in database, but it is there...

    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 Code:
    <?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 Code:
    <?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";
        }
    }
    ?>

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    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.
    I can't really think of anything to write here now...

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •