MyBB Community Forums

Full Version: Problem with displaying username characters outside forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey

Im just trying to have the latest threads show up outside the forum on my main site.

So im doing a simple mysql_select and pulling the latest threads. All OK.

But for some strange reason, the special chars in users usernames are showing up as "??"

for example..

[TJ] ~ H??dC�??

But, when i directly look into the database, i see the username been stored as it should be correctly, [TJ] ~ HᵰяdCøяє.

the database is set to UTF8 and the page im outputting to is UTF8.

So im really confused, if mybb can display the username correctly, why carnt i show it correctly outside the forum? What am i missing?

$result = mysql_query("SELECT * FROM `mybb_threads` WHERE `fid` = '5' OR `fid` = '2' OR `fid` = '11' ORDER BY tid DESC LIMIT 8");

while ($row = mysql_fetch_assoc($result)) {

$subject = $row['subject'];
$tid = $row['tid'];
$lastposter = $row['lastposter'];

echo  "<li><img src=\"http://www.8baller.co.uk/forum/images-8baller/jump.gif\" style=\"vertical-align:middle;\"><a href=\"http://www.8baller.co.uk/forum/thread-$tid.html\" title=\"$subject\">$subject</a> $lastposter</li>";
}

Its the $lastposter var thats showing wierd characters. As said, its correct in the database and shows fine within mybb... but just shows wierd characters when i try show it outside mybb.. any help?
Check that the Content-Type meta tags are the same on both your forum and the page your displaying it on, I think it's a browser issue.
Hey

Yep it was all exactly the same content-type set in the header. BUT, iv now fixed it.. for some reason, adding this

mysql_query("SET NAMES 'utf8'");

before my latest thread selection query, outputs the rows in the correct character set. Strange.. but its working!