Jump to content

Recommended Posts

I have a weird problem related to characters encoding on my website

 

I have using a phpbb3 forum, and i have a french and russian forum.

 

I have built a menu showing the last posts of all forums

 

My problem is that when a post title includes weird character (french characters like "é à â î Ç" or russian characters) it will display incorrectly

 

I don't understand why, because the characters are displayed correctly inside the forums

 

What do i have to do?

Link to comment
https://forums.phpfreaks.com/topic/176383-problem-with-character-encoding/
Share on other sites

i already tryed that, just tryed again and it doesnt change anything :(

 

see by yourself:

 

http://www.anarcho-punk.net/

 

this is the script where the problem comes from (i include() this menu on the front page)

http://www.anarcho-punk.net/last2.php

 

As you can see the russian topic name is written "????????"

 

but when you click on the link, everything is good:

http://www.anarcho-punk.net/viewtopic.php?f=5&t=1981

Had a quick look at the headers sent with your site, the difference between the working one and the other one seems to be...

 

Content-Type: text/html; charset=UTF-8

 

Try calling this at the top of your page...

 

header("Content-Type: text/html; charset=UTF-8");

The header() call must be the VERY first thing in the file. No newlines, no nothing

So this is probably the problem.

 

I need to set UTF-8 in the left menu of my site.

 

So if i put the header() call inside my left menu script, it will not be the very first thing in the file when index.php loads

 

Even if i put the code in the first line of "last2.php", i get this error:

[phpBB Debug] PHP Notice: in file /last2.php on line 1: Cannot modify header information - headers already sent by (output started at /cache/tpl_Dark-Shines_overall_header.html.php:2)

 

so i have tryed to put the PHP code inside the beginning of "overall_header.html" but it doesn't change anything :(

If the problem still remains.... is there any differences in the MySQL code for the homepage and viewtopic.php? There may be a line like: mysql_query("SET NAMES 'charset_name'");

 

Where charset_name is UTF8, utf-8, utf8, or UTF-8.

 

Something to try in addition to the header() call if it still isn't working.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.