How to decode the result?

Discussion in 'PHP' started by a4tech, Apr 5, 2013.

  1. #1
    Hello, In my data base there are non English words. It looks 'word' store in database in this format.

    привет


    $test_function = "SELECT * FROM table1 WHERE word IN ('$new_k')";
    $check_row = $db->query($test_function);
    PHP:
    Here 'word' did not provide the correct output for non English words? What to do to get the non English word in real format.

    Please give me suggestion that i get the perfect output for word and how to adjust the syntax with out destroying it.

    Thank You.
     
    Solved! View solution.
    a4tech, Apr 5, 2013 IP
  2. #2
    Thats because its Russian.
    Use htmlentities.
    echo htmlentities($check_row->text)
    PHP:
     
    robzdc, Apr 5, 2013 IP
  3. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #3
    htmlentities transform an input into HTML Entities; html_entity_decode instead transform it in browser interpretable code.

    So for what I understood, OP need to show it on screen correctly so, converting it:

    htmlentities: привет
    html_entity_decode: привет

    If OP is then interested in searching a htmlentities encoded text in the database, this simple code may be of help.

    $word = "привет";
    $query = mysql_query("SELECT * FROM table1 WHERE word LIKE '%".htmlentities($word)."%'");
    while ($row = mysql_fetch_array($query)) {
      echo "<p>Possible: ".html_entity_decode($row['word'])."</p>";
    }
    PHP:
     
    YoGem, Apr 5, 2013 IP
  4. a4tech

    a4tech Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    YoGem Thank You.

    Your ideas very strong.
     
    a4tech, Apr 5, 2013 IP
  5. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #5
    You are very welcome ;)
     
    YoGem, Apr 5, 2013 IP