Search DB and output script needed

Discussion in 'PHP' started by MikeKB, Dec 10, 2006.

  1. #1
    I'm not a programmer but a linguist working on various languages for academic purposes. I'm preparing some dictionaries to post to the web.

    Does anybody know where I can find a simple php script that takes a search string from a user (from search box) and outputs what it finds from mysql? It would be helpful if it outputs full word matches.

    Everything I do on my website is in UTF-8 because I use a lot of the International Phonetic Alphabet (IPA) and alphabets of various Asian languages, unfortunately I've been having output problems when accessing the database. I'm not sure what the problem is. I had a php script saved in UTF-8, telling to output in UTF-8, the database was set up in UTF-8 (I think it was, but I might be missing something).

    Now I have a makeshift one searching CSV files (that's easy enough to save in UTF-8) and it works, however, I eventually want the database to work for streamlined purposes.

    If anybody has been through working with foreign scripts in mysql like this before and setting up how to output the displays correctly, your help would be appreciated.
     
    MikeKB, Dec 10, 2006 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    MAke sure you set the field types in the database and the character encoding to utf-8 in your html.
     
    matthewrobertbell, Dec 10, 2006 IP
  3. MikeKB

    MikeKB Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    We've already tried this.
    Strange thing was we started with a different encoding in the db, on default swedish collocation, and when we imported the database in UTF-8 format (the characters themselves, not changing the db settings), mysql changed all the characters to numbers so we couldn't actually read anything in mysql. Ironically, the search output was working at that point and displaying correctly (obviously if you're reading unicode code points, the html will render correctly). However, since I had to do more work on the data and needed a visual, I changed all the settings to UTF-8, deleted the sheet and imported it again.
    Ok, so now I can see and edit the data while working in the database, but everything outputs in question marks. I've been making webpages in UTF-8 since 2001 and know how to get things to display correctly in plain HTML. But this is my first experience workign with a database, and I'm not sure why this is happening.
     
    MikeKB, Dec 10, 2006 IP
  4. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe try using this to convert the data just before you pump it into the html?
     
    matthewrobertbell, Dec 10, 2006 IP
  5. MikeKB

    MikeKB Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks, that information looks very helpful.
     
    MikeKB, Dec 11, 2006 IP
  6. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #6
    I use iconv to convert strings from and to utf8..

    Peace,
     
    Barti1987, Dec 11, 2006 IP