Problems with UTF-8 string and database

Discussion in 'PHP' started by kaene, Oct 15, 2008.

  1. #1
    Hi, I have a text file, the content has some UTF-8 characters, and when I try to record it to a database (mysql) it doesn't record the UTF-8 characters, so I'm trying just to filter them to delete them all.

    Is there anyone who can help me? Both options are fine, find the way to record the string with UTF-8 characters or just filter and delete them all.

    I have the connection strings

    mysql_query("SET character_set_client=utf8");
    mysql_query("SET character_set_connection=utf8");
    mysql_query("SET character_set_results=utf8");

    I read the file with a simple

    $filecont = file_get_contents ($FileName);

    And then just the INSERT

    The database table collocation is utf8_general_ci




    Thank you very much.
     
    kaene, Oct 15, 2008 IP
  2. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    lp1051, Oct 15, 2008 IP
  3. kaene

    kaene Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, thanks, it seems that the problem was that some sources were coding with different code pages, I solved it with the mb_convert_encoding function
     
    kaene, Oct 17, 2008 IP