Raccoon
Raccoon

Reputation: 1427

utf8_general_ci causes broken characters

$sql = "SELECT bdId, bdTitle FROM board"; 
$result = dbQuery($sql);    
            for($i = 0; $i < 4; $i++)
            {   
                $row = dbFetchAssoc($result);
                $newsId = $row['bdId'];
                echo '<li><a href="index.php?view=detailedNews&newsId=' . '$newsId">' .$row['bdTitle'] . '</li>';
            }

I'm trying to echo non-english text from 'bdTitle' column which is stored as utf8_general_ci. However, that codes gives me bunch of questions marks like ' ????? . ????.?????? ' What's the problem here and how can I print the texts properly?

Upvotes: 0

Views: 1321

Answers (1)

pahan
pahan

Reputation: 2453

set utf-8 encoding for your database connection

$link = mysql_connect('localhost','user','pass'); 

mysql_set_charset('utf8',$link); 

Upvotes: 1

Related Questions