Abudayah
Abudayah

Reputation: 3875

fix encoding Arabic data from database

fix encoding Arabic data from database ?

    function postTitle()
            {
        $postdb = mysql_query("SELECT * FROM wtable");
        $post = mysql_fetch_assoc($postdb);
            echo mb_detect_encoding($post['posttitle'],"UTF-8,ISO-8859-1");
            }
echo postTitle();

datebase encode: utf8_general_ci

result:

????????? ?????????????? ????????? ????? ???????

Upvotes: 2

Views: 793

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117364

Assuming that the script is encoded UTF8 too, be sure that the connection also uses UTF8: Use this:

mysql_query('SET names UTF8');

....before the SELECT inside the function.

Upvotes: 3

Related Questions