Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: gekk0 on April 17, 2007, 01:33:16 AM

Title: Posted Characters coming up as "?" question marks
Post by: gekk0 on April 17, 2007, 01:33:16 AM
I'm using english UTF-8, and Chinese UTF-8 language sets on my forum,  and i'm having problems with some posted information being displayed as question marks like this:

门票:60rmb,包含一杯� �准饮料。

Also, sometimes 'nspb' appears too...does anyone know why this is happening / how to fix it?

Thanks

James
Title: Re: Posted Characters coming up as "?" question marks
Post by: Sarge on April 17, 2007, 06:03:48 AM
It seems a character set and/or collation issue to me. This "garbled characters" issue can happen, for example, when your database is in UTF-8, database connection character set and client charset is UTF-8, but database tables and/or table data have a different charset (ISO-8859-1 for example). Incompatible PHP charsets and page encodings don't help either. As you can see, there are quite a few variables that affect how data will be displayed.

1. As a first step towards solving this problem, go to phpMyAdmin and click on "Show MySQL system variables":

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg145.imageshack.us%2Fimg145%2F7466%2Fshowgn6.png&hash=306073279431ab1b9b8718393ff570ea)

Check charset and collation settings. Here's an example:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg83.imageshack.us%2Fimg83%2F4177%2Fcharsetsid3.png&hash=94d133e556580edd602f23c53ecf34c7)

2. Did you select UTF-8 during SMF installation?

3. Select the database where SMF tables are installed and note what collation is used for each table:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg151.imageshack.us%2Fimg151%2F992%2Ftablecharsetpr0.png&hash=8048bb24ec8a716371f710c08a44d7a4)

Click on a table and see what collation is specified for each varchar, tinytext and text field:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg157.imageshack.us%2Fimg157%2F4381%2Fdatacharsetrp1.png&hash=cfd7968de309acec93ff8c507d312239)

4. Check the contents of phpinfo(), or at least the values for:

Post your above settings here and I'll try to help you.
Title: Re: Posted Characters coming up as "?" question marks
Post by: Sarge on July 07, 2007, 04:17:30 AM
Hi, I'm browsing through older topics to see if they are resolved.

Have you been able to solve this issue? I found a solution that worked for another member with the same issue:
http://www.simplemachines.org/community/index.php?topic=166743.0
Title: Ynt: Posted Characters coming up as "?" question marks
Post by: tangch on December 01, 2007, 06:09:36 PM
Hi Sarge!

I have been following your post regarding the display of bad Chinese characters.
Well I'm having similiar problems (posted characters appearing as "?" question marks).
The difference is that my website is using Joomla (which is decoded with charset=UTF-8).
But I suppose your advice applies to most bad character issues if not all. In the following attached image you can see the character settings of my Joomla Database.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Finfoarchiv.com%2Fimages%2FSQL_settings.JPG&hash=03f617f55e2fc5e346f07a0e37392af9)

Do you think the different values are causing the bad character issue? Will a uniform value (UTF-8) correct the situation? Should I try changing all the values to UTF-8?

I look forward to your reply as this is an urgent issue to my website. Thanks in advanced.
Title: Re: Ynt: Posted Characters coming up as "?" question marks
Post by: Sarge on December 03, 2007, 07:00:35 AM
The difference is that my website is using Joomla (which is decoded with charset=UTF-8).

Then by all means get a backup of your database from phpMyAdmin, and/or from the control panel of your hosting account (if it supports database backups.)

But I suppose your advice applies to most bad character issues if not all.

No, this advice doesn't work for every issue related to character sets. It works for SMF installs that are marked as UTF-8 (there's no "Convert the database and data to UTF-8" in Admin > Forum Maintenance, but there's "Convert HTML-entities to UTF-8 characters") but the SMF tables and text fields are in latin1_swedish_ci. Otherwise, different approaches are needed.

Now, are you asking about 1) your Joomla! site, or 2) about your SMF forum integrated in Joomla?
Title: Re: Posted Characters coming up as "?" question marks
Post by: tangch on December 06, 2007, 05:53:22 AM
Hi Sarge,

Thanks for your reply. Actually I'm using a SMF forum integrated in Joomla (Joomla 1.0.13 and JSMF Bridge 2.0.1 by JoomlaHacks). I have decided to use GB2312 encoding instead of UTF-8. So far I don't see bad characters anymore.

But I have got another problems.

1. When an attachment with a Chinese file name is attached to a post and saved, the file could not be downloaded. I get the Error 404 when trying to download it. Well it displays normally with the correct name in the post. Then I changed the Attachment Settings. I deselected the encrypt attachment option. Now the attachment with Chinese file name can be downloaded but the name has been change to some alphabets and not the original Chinese file name given. Is this a bug?

2. An immediate automatic user login is denied ("Login error. Please check your cookie settings") even though the default settings in the administration are used. I know this is caused by the JSMF Bridge but I can't afford to uninstall the bridge since there is no other choices.

Can you maybe shed some light on these issues? Thanks!
Title: Re: Posted Characters coming up as "?" question marks
Post by: im1 on August 12, 2008, 06:21:32 PM
Hi,

I recently changed the setting of my charset to 'english'. Im not sure what it was before.
One of my members username got changed, it added another character. So I wanted to change the name back but i got this error:

Quote
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like'
File: /home/username/public_html/sitename/forum/Sources/Subs-Members.php
Line: 899

Do you know how i can resolve this?